How do i replace all tabs with one space using sed?
-
Man page to sed: https://www.lightnetics.com/post/3334
The sample file has tabs as shown by the ^I characters.
This is my first IP 10.50.20.1 grapes apples pears This^I^I^Iis the first block oranges PLUMS This is my second IP 10.50.20.2 This is my duplicate IP 10.50.20.2 grapes apples pears This is the second block oranges PLUMS This is my third IP 10.50.20.3 grapes apples pears This is the third block oranges plums
This command replaces the tabs with three spaces, but that's not what we want, we want just one space for any amount of tabs.
$ sed 's/\t/ /g' samplefile
This command will replace all tabs with one space.
$ sed 's/[[:space:]]\+/ /g' samplefile
© Lightnetics 2024