[Ilugc] Doubt in awk script

  • From: sanjay_chigurupati@xxxxxxxxx (Sanjay Chigurupati)
  • Date: Sat Oct 13 10:54:09 2007

Hi,
thats interesting. dint know cud use irc for that.

are there any forums/ user groups where one could get
feedback on code?

sometimes while coding, we get mistakes and fix it.
But the reason for mistake is not clear and the
information is not clear in books either.

thanks,
sanjay

--- Mrugesh Karnik <mrugeshkarnik@xxxxxxxxx> wrote:

On Friday 12 Oct 2007 12:10:56 Ashok Antony wrote:
hi all


in the below script, could any one explain me the
usage of  '1'

awk 'BEGIN{OFS=FS=",";c=1}
    {
     n=sprintf("%03d",c++)
     $3=$3n
     print c
    }
    1' "file"

Here's the reply from #awk@xxxxxxxxxxxxxxxx

[23:31] <karolisl> floyd_n_milan: awk '1' file
[23:31] <karolisl> try this one.
[23:31] <karolisl> it would work the same as cat.
[23:32] <floyd_n_milan> so what exactly does it do?
[23:33] <karolisl> floyd_n_milan: IMO, it works as :
or true in shell
[23:33] <floyd_n_milan> hmmm
[23:34] <floyd_n_milan> same as print then?
[23:34] <karolisl> (in this case)
[23:34] <karolisl> floyd_n_milan: one can omit print
[23:34] <karolisl> awk '/foo/'
[23:34] <karolisl> awk '/foo/' file
[23:34] <karolisl> would work as a grep/.
[23:34] <floyd_n_milan> it does :
[23:34] <karolisl> because, if a pattern/an
address/a condition is specified, 
awk defaults to print as an action for that block


-- 
----------------------------------------
Mrugesh Karnik
GPG Key 0xBA6F1DA8
Public key on http://wwwkeys.pgp.net
----------------------------------------
_______________________________________________
To unsubscribe, email ilugc-request@xxxxxxxxxxxxx
with 
"unsubscribe <password> <address>"
in the subject or body of the message.  
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc




       
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! 
FareChase.
http://farechase.yahoo.com/

Other related posts: