![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to access values of awk/nawk variables outside the awk/nawk block? | saniya | Shell Programming and Scripting | 5 | 05-13-2008 08:37 AM |
| nawk & awk | sd12 | UNIX for Advanced & Expert Users | 5 | 05-05-2008 11:46 AM |
| nawk/ksh help | DeltaX | Shell Programming and Scripting | 0 | 03-06-2008 03:54 PM |
| nawk -v to awk | kamel.seg | Shell Programming and Scripting | 2 | 12-18-2007 07:30 AM |
| nawk | whatisthis | Shell Programming and Scripting | 3 | 09-29-2004 02:44 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
nawk use
I found a command who prints x lines before and after a line who contain a searched string in a text file.
The command is : ------------------- nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=2 a=4 s="string" file1 ...where "b" and "a" are the number of lines to print before and after string "s". ------------------- It works very well but I can't understand the syntax, too difficult with "man nawk". Is that some one who will be able to comment this syntax ? Thank's in advance, best regards and happy new year. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|