Command line commands in Linux
In this post I maintain a list of useful commands that can be entered at the Linux command line.
- Look for a phrase in all files:
$ find . -type f -print0 | xargs -0 grep phrase_to_find
- Replace all occurences of a certain phrase in a collection of files:
perl -pi -e 's/monkey/I am crazy/g' `grep -l monkey *`
- Copy a directory and all its contents to another machine (preserving symbolic links!):
tar cf - directoryToCopy | ssh email@example.com "cd destination; tar xvf -"
In case there are more CPU cycles available than bandwidth, you may want to (un)compress while copying:
tar cfz - directoryToCopy | ssh firstname.lastname@example.org "cd destination; tar xvfz -"
- Listing of files sorted on size:
ls -l . | sort -n -k 5,1
11:57AM May 10, 2007
by Zeger Hendrikse in Linux |