How can I use sed or any utility to remove any word that begins with TRS-, I have tried sed
's/ERA.*//g'
but seems not to be working
Input:
23 TRS-458-9 345 235
45 TRS-42-5 423 000
76 300 234
Output:
23 345 235
45 423 000
76 300 234
How can I use sed or any utility to remove any word that begins with TRS-, I have tried sed
's/ERA.*//g'
but seems not to be working
Input:
23 TRS-458-9 345 235
45 TRS-42-5 423 000
76 300 234
Output:
23 345 235
45 423 000
76 300 234
$ sed "s/TRS-[^ ]* //g" file
23 345 235
45 423 000
76 300 234
Thanks
Hello,
One more solution for same.
awk '{for(i=1;i<=NF;i++) {if($i !~ /TRS/) {print $i}}}' file_name | xargs -n 3
Output will be as follows.
23 345 235
45 423 000
76 300 234
Thanks,
R. Singh
Using the same regex via awk
awk '{sub(/TRS-[^ ]* /,x)}1' infile
Or maybe a different approach could be used:
awk '{print $1, $(NF-1), $NF}' file