Commands by impinball (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

Create a bunch of dummy text files

Start another X session in a window
You might have Xnest (older) rather than Xephyr. You can experiment with other desktops eg: startx /usr/bin/start-kde -- /usr/bin/Xephyr :2 You can start X on a remote machine (although I'd recommend vnc for anything slower than a LAN): startx /usr/bin/ssh -X gnome-session -- /usr/bin/Xephyr :2 Or just start another X session locally talking to the remote backend:

List of macros defined by gcc
Lists all macros and their values defined by gcc.

list files recursively by size

Remove duplicate rows of an un-sorted file based on a single column
$F[0] filters using first word. $F[1] - 2nd, and so on.

Convert all MySQL tables and fields to UTF8
This loops through all tables and changes their collations to UTF8. You should backup beforehand though in case some data is lost in the process.

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

Simulate typing
this also generates errors (change 4 to higher number for more mistakes)

Remote execute command as sudoer via ssh
Example: remote install an application(wine). sshpass -p 'mypssword' ssh -t mysshloginname@ "echo 'mypassword' | sudo -S apt-get install wine" Tested on Ubuntu.

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

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: