Show the exit code of the last command:
echo $?
Reuse the last part of the previous command:
new_command !!:$
Remove new line from end of file
perl -pi -e 'chomp if eof' <filename>
Rename files from upper case filename to lower case
for i in *; do mv $i `echo $i | tr [:upper:] [:lower:]`; done
Show the 10 most used commands:
history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
Change file suffix
rename 's/\.old$/\.new/' *.old
find . -name "*.old" -exec rename 's/\.old$/.new/' '{}' \;
Recursive search and replace
find . -type f -exec sed -ie 's/old/new/g' {} \;
Reorder the columns of a CSV file (using , as separator)
awk -F, '{print $2,$1,$3}' OFS=, file
Start a web server that serves the current directory
python -m SimpleHTTPServer <port>
Make a program continue to run after logout from SSH
$ myprogram
Press <Ctrl>+Z
[1]+ Stopped myprogram
$ disown -h %1
$ bg 1
[1]+ myprogram &
$ logout