commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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.
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:
Very quick! Based only on the content sizes and the character counts of filenames. If both numbers are equal then two (or more) directories seem to be most likely identical.
if in doubt apply:
diff -rq path_to_dir1 path_to_dir2
AWK function taken from here:
A bitcoin "brainwallet" is a secret passphrase you carry in the "wallet" of your brain.
The Bitcoin Brainwallet Private Key Calculator calculates the standard base58 encoded bitcoin private key from your "brainwallet" passphrase.
The private key is the most important bitcoin number. All other numbers can be derived from it.
This command uses 3 other functions - all 3 are defined on my user page:
1) brainwallet_exponent() - search for Bitcoin Brainwallet Exponent Calculator
2) brainwallet_checksum() - search for Bitcoin Brainwallet Exponent Calculator
3) b58encode() - search for Bitcoin Brainwallet Base58 Encoder
Do make sure you use really strong, unpredictable passphrases (30+ characters)!
http:brainwallet.org can be used to check the accuracy of this calculator.
A bitcoin "brainwallet" is a secret passphrase you carry in your brain.
The Bitcoin Brainwallet Private Key Base58 Encoder is the third of three functions needed to calculate a bitcoin PRIVATE key from your "brainwallet" passphrase.
This base58 encoder uses the obase parameter of the amazing bc utility to convert from ASCII-hex to base58. Tech note: bc inserts line continuation backslashes, but the "read s" command automatically strips them out.
I hope that one day base58 will, like base64, be added to the amazing openssl utility.
Useful to add a timestamp to every line printed to stdout.
You can use `-Ins` instead of `-Iseconds` if you want more precision.
client$ while true; do read -n30 ui; echo $ui |openssl enc -aes-256-cbc -a -k PaSSw ; done | nc localhost 8877 | while read so; do decoded_so=`echo "$so"| openssl enc -d -a -aes-256-cbc -k PaSSw`; echo -e "Incoming: $decoded_so"; done
This will establish a simple encrypted chat with AES-256-CBC using netcat and openssl only.
Old drive with lots of music or unsorted drive? This command will play all mp3 files in a folder and after playing one song or pressing q, it will ask you if you want to delete the file.
Checks for syntax errors in PHP files modified in current working copy of a Git repository.
Creates a temporary ram partition
to make a 3gb partition (Defaults to 1gb)
Creates an incremental snapshot of individual folders.
Problem: I wanted to backup user data individually, using and incremental method. In this example, all user data is located in "/mnt/storage/profiles", and about 25 folders inside, each with a username ( /mnt/storage/profiles/mike; /mnt/storage/profiles/lucy ...)
I need each individual folder backed up, not the whole "/mnt/storage/profiles". So, using find while excluding directories depth and creating two variables (tarfile=username & desdir=destination), tar will create a .tgz file for each folder, resulting in a "mike_2013-12-05.tgz" and "lucy_2013-12-05.tgz".
Problem: I wanted to backup user data individually. In this example, all user data is located in "/mnt/storage/profiles", and about 25 folders inside, each with a username ( /mnt/storage/profiles/mike; /mnt/storage/profiles/lucy ...)
I need each individual folder backed up, not the whole "/mnt/storage/profiles". So, using find while excluding directories depth and creating two variables (tarfile=username & desdir=destination), tar will create a .tgz file for each folder, resulting in a "mike_full.tgz" and "lucy_full.tgz".
Alternative to mnikhil's ls/awk solution
Usage exaple cmd
echo 'Sure to continue ??'; read -n1 choi; if [ "$choi" = 'y' ] || [ "$choi" = 'Y' ]; then echo -e '\nExecuting..'; else echo 'Aborted'; fi
Find's all png's in the current folder and all of its children
pngcrushes all results.
This command is used to verify a sha256sum-formatted file hash list on IBM AIX or any other UNIX-like OS that has openssl but doesn't have sha256sum by default. Steps:
1: Save to the filesystem a script that:
A: Receives as arguments the two parts of one line of a sha256sum listing
B: Feeds a file into openssl on SHA256 standard input hash calculation mode, and saves the result
C: Compares the calculated hash against the one received as argument
D: Outputs the result in a sha256sum-like format
2: Make the script runnable
3: Feed the sha256sum listing to xargs, running the aforementioned script and passing 2 arguments at a time
This will strip out the relivent disk information from kvm. I'm using it to find disks on a SAN which are no longer in use.
basic find implementation for systems that don't actually have find, like an android console without busybox installed.
git gc should be run on all git repositories every 100 commits. This will help do do so if you have many git repositories ;-)