Thread: sed and hex
View Single Post
Old 11th July 2008
lvlamb's Avatar
lvlamb lvlamb is offline
Real Name: Louis V. Lambrecht
Spam Deminer
Join Date: May 2008
Location: .be
Posts: 221

Ooops! Right, checked my scripts and it is gsed I use to write a postgresql INSERT. VALUES must be single-quoted and comma-separated.

gsed 's/^/INSERT INTO metals (date,ticker,bid_am,ask_pm,stock,oi) VALUES (\o047/g ; s/$/\o047);/g ; s/\t/\o047,\o047/g' lme_tmp > ../sql/lme-$mydate.sql
With OpenBSD sed, the trick to use the newline character is to ... escape the new line as
sed 's/|/\
/g' infile > outfile
Similarly the tab can be escaped. Works on the command line, but not when cut'n pasted or mulled through an editor (darn things translate the tabs into spaces).

Well ... call me a traitor, but y scripts work fine with gawk and gsed.
Once in a while on rainy days, I review some scripts and try which lines work with the OpenBSD version, and which one's are better kept on the GNU version. Must have nothing else to do as if it ain't broke, why fix it?
Worse, I use gdate to parse international dates.
Never had the time to read Perl's Date::Manip
da more I know I know I know nuttin'
Reply With Quote