[nSLUG] gawk... @#^&##&^!!- ;-)

Stephen Gregory nslug at kernelpanic.ca
Thu Mar 11 19:52:13 AST 2010


Jason Kenney wrote:
>
> I think awk is substituting the variable new_id (or alternatively the 
> variable here, it doesn't matter which) for its 'value'.  I believe that 
> the 'value' is the address for the start of the string (

This is likely what is happening:

echo "0 foo" | gawk '{ zero=$1; print bar; print $bar }'
0
0 foo


In the above example bar is set to 0 by bar=$1. So $bar (with a $) 
becomes $0 which is the whole line.


On Thu, Mar 11, 2010 at 4:11 PM, David Potter <dlpotter at eastlink.ca> wrote:
 >>>>>
>>>>>     cat /tmp/hash_combined | sed -e 's/[ \t\-]*//g' | gawk -F: 

you can skip sed by using:

	awk -F'[\\t \\-:]+'

I bet you tried something like this but it didn't work. That is what 
always happens to me and I use sed like you did. I find the following 
helpful when trying to set FS (-F) in gawk/awk:

  gawk -F'[\\t \\-:]+'  'BEGIN {print FS} '
  [\t \-:]+






More information about the nSLUG mailing list