Theodoros Emmanouilidis

Notes & Thoughts

Remove Leading Whitespace Using Sed

February14

Sometimes a data file contains whitespace before the actual data. The following command will remove that whitespace.

1
cat original_file.txt | sed -e 's,^ *,,' > new_file.txt

Replace Spaces & Tabs With Spaces In File

February14

The following command will substitute all tabs & spaces in a file with just spaces. Very usefull if you want to prepare a file as csv or inject the data contained in a database table.

1
sed -r 's/[[:blank:]]/ /g' original_file > new_file