Wednesday, July 2, 2008

Delete one or more space using sed- bash


Input file: 
$ cat test.txt
one two three       four
1   2 3  4
i     ii   iii           iv

Sed code to delete/remove one or more space from a file. (Basically combine one or more space to a single space)

$ sed 's/[ \t]\+/ /g' test.txt > test.txt.1

$ cat test.txt.1
one two three four
1 2 3 4
i ii iii iv

No comments:

© Jadu Saikia www.UNIXCL.com