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:
* Find all file sizes and file names from the current directory down (replace "." with a target directory as needed).
* sort the file sizes in numeric order
* List only the duplicated file sizes
* drop the file sizes so there are simply a list of files (retain order)
* calculate md5sums on all of the files
* replace the first instance of two spaces (md5sum output) with a \0
* drop the unique md5sums so only duplicate files remain listed
* Use AWK to aggregate identical files on one line.
* Remove the blank line from the beginning (This was done more efficiently by putting another "IF" into the AWK command, but then the whole line exceeded the 255 char limit).
>>>> Each output line contains the md5sum and then all of the files that have that identical md5sum. All fields are \0 delimited. All records are \n delimited.
I did not come up with this one myself, but found this somewhere else several months ago.
This command will delete all files and folders except 'skipme'. it could be a file or a folder.
When you do a ls -1 | xargs rm it wouldn't workd because those files have spaces. So you must use
find -print0 and xargs -0
My first command :) I made this command to log public addresses of a virtual interface who connects random VPN servers around the world.
Sorts by latest modified files by looking to current directory and all subdirectories
This script can be used to download enclosed files from a RSS feed. For example, it can be used to download mp3 files from a podcasts RSS feed.
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
schema & tables
To export into another backends style, just change backend to one of: access, sybase, oracle, postgres, mysql and sqlite
Solves these pesky errors you see in the Apache log:
[Fri Jun 28 17:51:00 2013] [emerg] (28)No space left on device: Couldn't create accept lock (/monsoon/opt/apache2/logs/accept.lock.356) (5)
Naturally, can be used to get rid of other semaphores. Note: change the apache user in accordance to your ENV.
On Linux substitute pbpaste with `xsel --clipboard --output` or `xclip -selection clipboard -o` (untested)
Goes through all files in the directory specified, uses `stat` to print out last modification time, then sorts numerically in reverse, then uses cut to remove the modified epoch timestamp and finally head to only output the last 10 modified files.
Note that on a Mac `stat` won't work like this, you'll need to use either:
find . -type f -print0 | xargs -0 stat -f '%m%t%Sm %12z %N' | sort -nr | cut -f2- | head
or alternatively do a `brew install coreutils` and then replace `stat` with `gstat` in the original command.
first grep all href images then sed the url part then wget
Recursively list all files in the current directory & get their md5sum, even if the filename has bad characters.
The directories are created in the local host with the same structure below of a remote base directory, including the 'basedir' in case that it does not exists.
You must replace user and remotehost (or IP address) with your proper values
ssh will ask for the password of the user in remotehost, unless you had included properly your hostname in the remote .ssh/known_hosts file.
Do the unlock KDE screen saver locked session with lightdm display manager used in Kubuntu 12.10 +
If you have a directory with lot of backups (full backups I mean), when it gets to some size, you could want to empty some space. With this command you'll remove half of the files. The command assumes that your backup files starts with YYYYMMDD or that they go some alphabetical order.
This is usefull to diff 2 paths in branches of software, or in different versions of a same zip file. So you can get the real file diff.