unix - AWK or SED to remove pattern from every line while using grep -
i have grep 2 columns , suppose col1 , col2. in col2 want remove pattern occurs in every line. how use awk/sed purpose?
suppose ps -eaf | grep b result following output:
col1 col2 col3 1 a/b/rac 123 2 a/b/rac1 456 3 a/b/rac3 789 i want output stored in file :
1 rac 2 rac1 3 rac3
vaguely speaking, might want:
$ awk 'sub(/.*b\//,"",$2){print $1, $2}' file 1 rac 2 rac1 3 rac3 assuming file contains:
col1 col2 col3 1 a/b/rac 123 2 a/b/rac1 456 3 a/b/rac3 789
Comments
Post a Comment