Commands by miccaman (20)

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

Calculates the number of physical cores considering HyperThreading in AWK
Check whether hyperthreading is enabled or not. a better solution as nproc should work on all OS with awk

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

Write comments to your history.
A null operation with the name 'comment', allowing comments to be written to HISTFILE. Prepending '#' to a command will *not* write the command to the history file, although it will be available for the current session, thus '#' is not useful for keeping track of comments past the current session.

Clone perms and owner group from one file to another
Copy both perms and owner group from one file to another.

Recursively remove all files in a CVS directory
This will search all directories and ignore the CVS ones. Then it will search all files in the resulting directories and act on them.

Generate a 18 character password, print the password and sha512 salted hash
Generate a 18 character password from character set a-zA-Z0-9 from /dev/urandom, pipe the output to Python which prints the password on standard out and in crypt sha512 form.

converting horizontal line to vertical line

convert single digit to double digits
Uses 'rename' to pad zeros in front of first existing number in each filename. The "--" is not required, but it will prevent errors on filenames which start with "-". You can change the "2d" to any number you want, equaling the total numeric output: aka, 4d = ????, 8d = ????????, etc. I setup a handful of handy functions to this effect (because I couldn't figure out how to insert a var for the value) in the form of 'padnum?', such as: padnum5 () { /usr/bin/rename 's/\d+/sprintf("%05d",$&)/e' -- $@ } Which would change a file "foo-1.txt" to "foo-00001.txt"

Skype conversation logs to IRC-format logs

Get a diff of two json arrays
jq is amazing for manipulating json on the commandline, but the developers have some weird ideas about how to handle shell redirections. This command works around them. Further reading:

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: