Why don't you simplify your code? It's looking too complex to understand really.
for myfile in `find . -name "R*VER" -mtime +1`
do
echo "Processing $myfile"
# did you mean to use -l instead of -H by any chance?
# Two conditions on RHS and LHS do not produce similar output.
somestr=`grep -H ^err $myfile || echo "$myfile:No error"`
echo " somestr=$somestr"
echo $somestr | awk -F~ '{print $1"\t"$2"\t"$7"\t"$8"\t"$9"\t"$10}
done
Usually I recommend to make it work first using simpler syntax, before you try to make it look more nerdy by putting it all on one single line to impress others. :)Using the tilde (~) symbol as delimiter in the file name, can I extract the fields I want so I get an output like this
Yes. I do not see any restrictions on which char can and can't be used as delim.I'd like to do this is one pass so I can generate a SQL script with INSERT statements...Can it be done?
Yes, you're already on the correct path. You just need to adjust print statement inside the awk once you get it to work.
thekashyap
Practically a Posting Shark
811 posts since Feb 2007
Reputation Points: 254
Solved Threads: 75