awk -- escaping the delimiter
Okay, lets say I have the following file:
Code:
var0:0x9453!var1:Some random string!var2:"Stop!" the woman!var3:00432123432123432885
etc, etc, etc.
Okay, now what I want to do is to be able to break out the various data points with some delimiter -- in this case it would be the !, however, in the "real" file it would probably be :. I would expect to use awk on this line (after tailing the last line, which is the only line I'm really interested in) by looping through the number of times I need to to get all the data. So, the loop would look something like this:
Code:
LINE=`tail -n1 filename`
for i in 0 1 2 3 ; do
let j=i+1
CMDSTR="VAR${i}=`echo $LINE | awk -f! '{print \$${j}}'`"
eval $CMDSTR
done
But, the problem comes in where I have the ! after var2's Stop!. So, what I need to do is to figure a way to allow escaping (or quoting) of the "text" that is in each field so that I don't chunk myself on the awk command.
Any ideas?