Reputation: 721
I have a shell script:
a ab.mi
3 jm.mi
56 uh.mi
I want to remove .mi from the 2nd column and make it like:
a ab
3 jm
56 uh
How can I do this with shell script?
Upvotes: 0
Views: 339
Reputation: 85883
If you really just want to remove the string .mi
then a simple sed
substitution will do:
$ sed 's/[.]mi//' file
a ab
3 jm
56 uh
If you really want to restrict to the second column awk
is better choice but with sed
you could do:
$ sed -r 's/(\S+\s+\S+)[.]mi/\1/' file
a ab
3 jm
56 uh
Upvotes: 1
Reputation: 123658
Using awk
:
awk 'gsub("\.mi", "", $2)1' inputfile
This would remove .mi
from the second column.
Upvotes: 2