Commands by lucaswang (1)

What's this?

commandlinefu.com 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

Display total Kb/Mb/Gb of a folder and each file

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" }

diff files while disregarding indentation and trailing white space

Find default gateway (proper at ppp connections too)

Download Youtube Playlist
This will download a Youtube playlist and mostly anything http://code.google.com/apis/youtube/2.0/reference.html#Video_Feeds The files will be saved by $id.flv

Let your computer lull you to sleep
Can change language and speed, see espeak man page for options. (Install espeak in your linux distro via yum or apt-get) For insomniacs you may need to enclose in a while true; do ...; done loop ;)

Backup your hard drive with dd
This will create an exact duplicate image of your hard drive that you can then restore by simply reversing the "if" & "of" locations. $ sudo dd if=/media/disk/backup/sda.backup of=/dev/sda Alternatively, you can use an SSH connection to do your backups: $dd if=/dev/sda | ssh user@ssh.server.com dd of=~/backup/sda.backup

Number of CPU's in a system
This appears to do the same. Utility is verified to be present on Ubuntu and OpenSuse out-of-the-box.

Decrypt MD5
Decrypt MD5 , replace 1cb251ec0d568de6a929b520c4aed8d1 with the MD5 string you want to decrypt

The command used by applications in OS X to determine whether a plist is "good". from Ed Marczak.
The check an entire folder is a one-liner: plutil -lint * | grep -v OK$ from Ed Marczak


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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: