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

David Potter dlpotter at eastlink.ca
Fri Mar 12 08:14:38 AST 2010


Stephen Gregory wrote:
> 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.
>   
That makes sense...
>
> 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 \-:]+
>   
I can say  with some certainty that I didn't... ;-) But that's a good tip.

I looked for more information on complex field separators without much
luck, does the '+' allow matches to multiple and single occurrences of
any/all of the characters. In this instance I want to also match ':' so
I was scrubbing before invoking gawk.

Thanks all!

David
>
>
> _______________________________________________
> nSLUG mailing list
> nSLUG at nslug.ns.ca
> http://nslug.ns.ca/mailman/listinfo/nslug
>
>   



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nslug.ns.ca/mailman/private/nslug/attachments/20100312/dfcb74b6/attachment-0002.html>


More information about the nSLUG mailing list