Greetings!
Some of my files list hardware errors (we test electronic components), some have none. If the file name has no errors, I still want to display a message like "No error", else I display the error from the file itself.
I came up with this (with help)
for myfile in `find . -name "R*VER" -mtime +1`
do
somestr=`grep -H ^err $myfile || echo -e "$myfile\tNo error"`
echo "$somestr" |sed 's:./::;s:tmp/::;s/:/\t/;'
echo $somestr | awk -F~ '{print $1"\t"$2"\t"$7"\t"$8"\t"$9"\t"$10}' | sed 's:./::;s:tmp/::;'
done
It works but outputs on two lines i.e.
RRR1~COS~COSMETICS~99537~jgmdtv132~1~P~R22-200~029053252648~20110607~094718.VER No error
RRR1 COS P R22-200 029053252648 20110607
RRR1~COS~COSMETICS~ETT03~jgm14652.~1~F~R16-300~000894980523~20110607~084053.VER err ->IR Remote Key 1 3310 err
RRR1 COS F R16-300 000894980523 20110607
I am looking to generate dynamically a SQL script with insert statements like so:
INSERT INTO MYTABLE (COL1,COL2,COL3,COL4,COL5,COL6,COL7,COL8)
VALUES ('RRR1~COS~COSMETICS~99537~jgmdtv132~1~P~R22-200~029053252648~20110607~094718.VER','No error','RRR1','COS','P','R22-200','029053252648','20110607');
INSERT INTO MYTABLE (COL1,COL2,COL3,COL4,COL5,COL6,COL7,COL8)
VALUES ('RRR1~COS~COSMETICS~ETT03~jgm14652.~1~F~R16-300~000894980523~20110607~084053.VER',' err ->IR Remote Key 1 3310 err','RRR1','COS','P','R16-300','000894980523','20110607');
All I would need to do is wrap both lines but I am not clear how to do it (still learning awk/sed). Is it possible?
Thanks for your help.