Search Results

Search: Posts Made By: p.bhaskar
4,806
Posted By Scrutinizer
Try: awk '{ A[NR%(n+1)]=$0 }; $0~s...
Try:
awk '{ A[NR%(n+1)]=$0 }; $0~s {i=(NR-n)%(n+1); if (i in A) print A[i] }' s='c\\[o\\]mp' n=2 infile

or
awk '{ A[NR%(n+1)]=$0 }; $0~s {i=(NR-n)%(n+1); if (i in A) print A[i] }' s='c.o.mp'...
4,806
Posted By Scrutinizer
Then use n=2
Then use n=2
4,806
Posted By Scrutinizer
Use n=26 instead of n=4 -- On...
Use n=26 instead of n=4




--
On Solaris use /usr/xpg4/bin/awk instead of awk
4,806
Posted By grep_me
Use this code. Just one line would do the job for...
Use this code. Just one line would do the job for you
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=0 s="comp" file.txt

You can change the "b" and...
4,806
Posted By Corona688
grep is not a programming language. it can't be...
grep is not a programming language. it can't be told to rewind 2 lines and print if it finds a match.

awk is a programming language and, while it can't rewind, it can save lines for later:

awk...
Showing results 1 to 5 of 5

 
All times are GMT -4. The time now is 03:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy