Commands by earthdan (1)

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

rsync + find
rsync from source to dest all between >30

Create and replay macros in vim
You can record, then replay a series of keystrokes in vim. In command mode 'q', then a letter [a-zA-Z] starts macro recording mode. Enter a series of vim commands. When done, enter command mode again, and press 'q' to stop recording. To replay, enter command mode, then press @{letter}

Benchmark report generator
Nicely display in html format a detailed report of the machine, including cpu benchmarks.

Carriage return for reprinting on the same line
The above code is just an example of printing on the same line, hit Ctrl + C to stop When using echo -ne "something\r", echo will: - print "something" - dont print a new line (-n) - interpret \r as carriage return, going back to the start of the line (-e) Remember to print some white spaces after the output if your command will print lines of different sizes, mainly if one line will be smaller than the previous Edit from reading comments: You can achieve the same effect using printf (more standardized than echo): while true; do printf "%-80s\r" "$(date)"; sleep 1; done

grep processes list avoiding the grep itself
Trick to avoid the form: grep process | grep - v grep

decoding Active Directory date format
When Ldapsearch queries an Active directory server, all the dates are shown using a timestamp of 18 digits. This perl regexp decodes them in a more human friendly notation. 11644473600 corresponds to some microsoft epoch.

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Verify if user account exists in Linux / Unix

Multiplication table
The multiplication table for math study

download file1 file2 file3 file4 .... file 100

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: