![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
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 |
| so difficult question about using grep | shrimpy | UNIX for Dummies Questions & Answers | 2 | 03-22-2008 12:19 AM |
| A difficult script (for me) | DNAx86 | Shell Programming and Scripting | 2 | 01-07-2008 04:04 PM |
| difficult sed command | Dave724001 | UNIX for Advanced & Expert Users | 17 | 09-29-2006 06:11 AM |
| Difficult Filtering Problem | Piyush | UNIX for Advanced & Expert Users | 1 | 06-30-2003 05:06 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I will try to 'decipher' that one-liner awk code
Code:
awk -v before=4 -v after=4 -v search="string" '
--current > 0 {
print
}
$0 ~ search{
if ( before ) {
for ( current=before+1 ; current>1 ; current-- ) {
print rec[(NR-current+1)%before]
}
}
print
current=after
}
before{
rec[NR%before]=$0
}' file1
The original one-liner is taking a lot of shortcut and default. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|