unix - How to print column offset within each matching line in grep -
by passing -o -n grep can output matching parts of pattern within file, , line number on each match found.
how can print column offset within line @ pattern found?
i think able mimic same thing you're doing awk. referencing awk manual:
http://www.staff.science.uu.nl/~oostr102/docs/nawk/nawk_92.html
here's file looks like:
this,is,a,test,line this, ,a,test,line,with,the,second,field,blank this, is,another,test,line,with,a,blank,in,the,second,field,but,the,field,isnt,blank this, ,is,another,line,with,a,blank,second,field
and here's command ran:
awk '{regex = "test"; = match($0, regex); print "regex: ",where," on line ",nr}' test
and output:
regex: 11 on line 1 regex: 10 on line 2 regex: 18 on line 3 regex: 0 on line 4
i did quick , dirty, i'm hoping helps enough need be.
Comments
Post a Comment