Re: Possible to set field separator on command line dbaccess
Posted in 1996
On Wed, 26 Jun 1996, Matt Silveira wrote:
} Hi all,
}
} I've been battling with this problem and have had no luck!
} I am trying to grab a query from the command line and redirect it to a file in the hopes
} that I can delimit the file that dbaccess returns
} I have it running on a Sun with Solaris 2.4 and Informix 5.x
}
} The script (not exact model) looks something like this:
}
} >!#/bin/sh
} >#
} >#
} >dbaccess databasename << EOF > /tmp/outputfile
} >
} >select field1, field2, from table where field1 like "foobar%"
} >EOF
} So, if I run the script above, named "clueless", from the command line like so:
} thor% clueless
}
} I get an output file that looks something like this:
}
} (added \\n for clarity)
}
} foobar1 ABC \\n
} foobar12 \\n
} foobar1233 ABC
} foobar12345 DEF
} foobar124556 DEF
} foobar2545 \\n
} foobar23456 \\n
}
} Please write to me or post to the group.
}
} Matt Silveira
} msilveir@campus.mci.net
}
Matt,
Stop battling. You should use unload instead, as in
unload to "yourfile.unl"
select field1, field2, from table where field1 like "foobar%"
run it the same way: dbaccess yourdb yoursql (with or without .sql)
The output goes to the file you designated in the unload. Default
delimiters are |. Two pipes ( || ) with nothing between signify
null. Great fun for sed or awk!
Yours,
Nick
*********************************
Nick Nobbe, Library of Congress
NLS/BPH
mail: nnob@loc.gov
*********************************