Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 447

Print substring of column based on position filter in awk

$
0
0

I have a file with following 3 columns

1   a1  abcd2   b1  acdb3   c1  abcd 

I need to extract/print rows based on substring of column3 on position filter (2=="b"), so the output should be

1   a1  abcd3   c1  abcd 

Based on (Print substring of column in awk based on filter) I have tried:

awk -F '\t' -v OFS='\t''{ $3=substr($3,2,1); print $0 }' a.txt 

Viewing all articles
Browse latest Browse all 447

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>