15 February 2011

Some Useful *nix Commands

Find files for some action (echo in this example) in current directory and all subdirectories:

$ find . -name '*.php' | while read file; do echo $file; done

Expand tabs to spaces (tab = 4 spaces):

$ expand -t 4 FILE > FILE.new && mv FILE.new FILE

And remove trailing whitespaces:

$ sed -i 's/[ \t]*$//g' FILE

No comments: