Theodoros Emmanouilidis

Notes & Thoughts

Remove Leading Whitespace Using Sed


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

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

Replace Spaces & Tabs With Spaces In File


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.

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

How To Remount As Read-Write A Read Only Filesystem


So simple but yet so usefull!

If you have to deal with a failling disk or similar emergency situations and you have to remount as read-write a read only filesystem….

just type

mount -o remount,rw /

ta da!

Make A List With All Unique Items In A List Python


This is just an one-liner, but very useful and convenient.

Suppose we have a python list


and we only want to return a list containing all unique elements of that list. We can use the “set” python command and construct a new list with all the unique elements of the original list.


print list_unique


Python rocks!!

« Older EntriesNewer Entries »