0
score
|
Concatenate PDF files using GhostScript$ gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=output.pdf -dBATCH file1.pdf file2.pdf file3.pdf |
0
score
|
Format text with long lines to text with fixed width$ fmt -s -w80 file.txt |
0
score
|
Come back quickly to the current directory after doing some temporary work somewhere else$ pushd /some/where/else; work; cd /somewhere; work; cd /another/place; popd |
0
score
|
Export a git project to a directory$ git archive master | tar x -C /path/to/dir/to/export |
0
score
|
Delete all tables of a mysql database$ mysql --defaults-file=my.cnf -e 'show tables' | while read t; do mysql --defaults-file=my.cnt -e 'drop table '$t; done |
0
score
|
Run remote X11 applications with ssh$ ssh -X servername |
0
score
|
Calculate the total disk space used by a list of files or directories$ du -s file1 dir1 | awk '{sum += $1} END {print sum}' |
0
score
|
Check the performance of a script by re-running many times while measuring the running time$ for i in {1..10}; do time curl http://localhost:8000 >/dev/null; done 2>&1 | grep real |
0
score
|
0
score
|
Recursively remove all empty sub-directories from a directory tree$ find . -type d | tac | xargs rmdir 2>/dev/null |
0
score
|
Remove all the versioned-but-empty directories from a Subversion checkout$ find . -name .svn -type d | while read ss; do dir=$(dirname "$ss"); test $(ls -a "$dir" | wc -l) == 3 && echo "svn rm \"$dir\""; done |
0
score
|
Create a sequence of integer numbers$ echo {4..-9} |
0
score
|
Redirect the output of the time builtin command$ { time command; } > out.out 2> time+err.out |
0
score
|
Copy a directory with a large number of files to another server$ tar cp -C /path/to/dir . | ssh server2 'tar x -C /path/to/target' |
0
score
|
Redirect the output of multiple commands$ { cmd1 ; cmd2 ; cmd3 ; } > out.out 2> err.out |
0
score
|
View a file with line numbers$ grep -n ^ /path/to/file | less |
0
score
|
Print the n-th and m-th line of a file$ sed -ne '101 p' -e '106 p' /path/to/the/file |
0
score
|
Repeat the previous command but with a string replacement$ ^geomtry^geometry |
0
score
|
0
score
|
Use rsync instead of cp to get a progress indicator when copying large files$ rsync --progress largefile.gz somewhere/else/ |
0
score
|
Unpack all of the .tar.bz2 files in current directory$ for FILE in *; do tar -jxf $FILE; done |
0
score
|
Create and restore backups using cpio$ find . -xdev -print0 | cpio -oa0V | gzip > path_to_save.cpio.gz |
0
score
|
Alert me by email when a disconnected or unreachable server comes back online$ while ! ping -c1 the_host_down; do sleep 1; done && date | mail -s 'the host is back!' me@example.com |
0
score
|
Add timestamp to the output of ping$ ping some_host | while read LINE; do echo $(date): $LINE; done |
0
score
|
Test a one-liner with echo commands first, pipe to bash when ready$ paste <(ls) <(ls | tr A-Z a-z) | while read OLD NEW; do echo mv -v $OLD $NEW; done | sh |