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 |
0
score
|
Find the most recently modified files in a directory and all subdirectories$ find /path/to/dir -type f | perl -ne 'chomp(@files = <>); my $p = 9; foreach my $f (sort { (stat($a))[$p] <=> (stat($b))[$p] } @files) { print scalar localtime((stat($f))[$p]), "\t", $f, "\n" }' | tail |
0
score
|
Delete unversioned files in a Subversion checkout directory and all subdirectories$ svn st | grep ^? | sed -e 's/^? *//' | xargs -i{} echo rm -fr "{}" |
0
score
|
Get the available space on a partition as a single numeric value$ df /path/to/dir | sed -ne 2p | awk '{print $4}' |
0
score
|
Schedule a one-time task using "at" command and intuitive date specifications$ at now + 30 minutes |
0
score
|
Aliases the ls command to display the way I like it$ alias ls='ls -lhGpt --color=always' |