For Programmers: Free Programming Magazines  


Home > Archive > AWK > December 2004 > syntax explanation needed









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author syntax explanation needed
Robert Katz

2004-12-27, 8:55 am

There have been many threads that required a re-arrangement of the input
record. The first proposal was '$1 = $1'

Followups pointed out the the line won't print if $1 = "" or $1 == 0, so
a fix to that was '{$1 = $1}1'

Now I can explain that, I said to myself; since } ends a line, the above
is equivalent to

' {$1 = $1}
1'

The first action line rearranges the input line, the second expression
is always true, so now we print the rearranged line.

Kenny countered the solution of '{$1 = $1}1' with '($1 = $1)1'. Now
that I'm not sure I understand.

What does 'expr expr expr' mean?
When is 'expr expr expr' the same as 'expr || expr || expr' ?

what does '($1 = $1)1' do? and why is it better than '{$1 = $1}1' ?

--
Regards,

---Robert
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com