Commands by marrowsuck (3)

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

Removing images by size
Removes all png files whose geometry is not 280x190 pixels

Insert the last command without the last argument (bash)
$/usr/sbin/ab2 -f TLS1 -S -n 1000 -c 100 -t 2 then $!:- is the same as $/usr/sbin/ab2 -f TLS1 -S -n 1000 -c 100 -t 2

MySQL: Slice out a specific table from the output of mysqldump
Only filters the statement related to a specific table ('departments', in the example), from the output of mysqldump

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

Join the content of a bash array with commas
This type of join is clearly documented in the bash manual. Only the first character of IFS is used for the delimiter.

list files recursively by size

purge installed but unused linux headers, image, or modules
will purge: only installed apps: /^ii/!d avoiding current kernel stuff: /'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d using app names: s/^[^ ]* [^ ]* \([^ ]*\).*/\1/ avoiding stuff without a version number: /[0-9]/!d

This is how you should push a string in a command's stdin.
Don't do this: $echo word | command Using a bash "here strings" and "here documents" look leeter than piping echo into the command. Also prevents subshell execution. Word is also expanded as usual.

OSX command to take badly formatted xml from the clipboard, cleans it up and puts it back into the clipboard.
This command can be used with xclip or xsel for use on a linux box.

convert uppercase files to lowercase files

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: