![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| please explain the below | mail2sant | Shell Programming and Scripting | 1 | 04-04-2008 05:04 AM |
| explain plz | avikal | Shell Programming and Scripting | 2 | 04-03-2008 08:11 AM |
| Please can any one explain this ${0##/} | gadege | Shell Programming and Scripting | 2 | 04-01-2008 12:26 PM |
| please explain this | dummy_needhelp | Shell Programming and Scripting | 2 | 10-14-2007 10:17 PM |
| Can anyone explain plz | r_W213 | UNIX for Advanced & Expert Users | 3 | 03-27-2007 01:52 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
can anyone explain this codes here?
nawk 'FNR > 3 {printf("%s%c", $0, OFS)}END{print ""}' "$1" > "$1".out && mv "$1
".out "$1" what is FNR? or printf("%s%c",$0, OFS)}? sorry..im lost... |
| Forum Sponsor | ||
|
|
|
|||
|
The FNR variable contains the number of lines read, but is reset for each file read. The NR variable accumulates for all files read. Therefore if you execute an awk script with two files as arguments, with each containing 10 lines:
nawk '{print NR}' file file2 nawk '{print FNR}' file file2 the first program would print the numbers 1 through 20, while the second would print the numbers 1 through 10 twice, once for each file. printf is used to print the output into the file instead of screen. inside the printf %s is used for string printing and %c is used for character printing. that is $0 as string and OFS is out field separator as character other then space which is default. |