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:
Liked command 4077 so I improved it, by doing all text manipulation with sed.
"Run this as root, it will be helpful to quickly get information about the loaded kernel modules." THX mohan43u
Run this as root, it will be helpful to quickly get information about the loaded kernel modules.
With this form you dont need to cut out target directory using grep/sed/etc.
The command find search commands with size zero and erase them.
I took java to make the find command simpler and to state that it works for any language supported by cpp.
cpp is the C/C++ preprocessor (interprets macros, removes comments, inserts includes, resolves trigraphs). The -fpreprocessor option tells cpp to assume the input has already been preprocessed so it will only replace comment lines with blank lines.
The -L 1 option tells xargs to launch one process for each line, indeed cpp can only process one file at the time...
Figures out total line contribution per author for an entire GIT repo. Includes binary files, which kind of mess up the true count.
If crashes or takes too long, mess with the ls-file option at the start:
git ls-files -x "*pdf" -x "*psd" -x "*tif" to remove really random binary files
git ls-files "*.py" "*.html" "*.css" to only include specific file types
Based off my original SVN version: http://www.commandlinefu.com/commands/view/2787/prints-total-line-count-contribution-per-user-for-an-svn-repository
not my cmd... found on the web
Nice command to create a list, you can create too with for command, but this is so faster.
Calculates the size on disk for each package installed on the filesystem (or removed but not purged). This is missing the
| sort -rn
which would put the biggest packges on top. That was purposely left out as the command is slightly on the slow side
Also you may need to run this as root as some files can only be checked by du if you can read them ;)
Searches for all .project files in current folder and below and uses "svn info" to get the last changed revision. The last sed joins every two lines.
List files and pass to openssl to calculate the hash for each file.
I needed a way to search all files in a web directory that contained a certain string, and replace that string with another string. In the example, I am searching for "askapache" and replacing that string with "htaccess". I wanted this to happen as a cron job, and it was important that this happened as fast as possible while at the same time not hogging the CPU since the machine is a server.
So this script uses the nice command to run the sh shell with the command, which makes the whole thing run with priority 19, meaning it won't hog CPU processing. And the -P5 option to the xargs command means it will run 5 separate grep and sed processes simultaneously, so this is much much faster than running a single grep or sed. You may want to do -P0 which is unlimited if you aren't worried about too many processes or if you don't have to deal with process killers in the bg.
Also, the -m1 command to grep means stop grepping this file for matches after the first match, which also saves time.
No need to loop when we have `xargs`. The sed command filters out the first line of `show databases` output, which is always "Database".
change the *.avi to whatever you want to match, you can remove it altogether if you want to check all files.
You're behind on your TV catch-up, but how far behind? This command tries to open mplayer against all files in the current dir. If it's a video file it will contain ID_LENGTH, which is summed and output in hours, minutes and seconds.
Someone better at awk could probably reduce this down a lot.
List all text files in the current directory.
This dup finder saves time by comparing size first, then md5sum, it doesn't delete anything, just lists them.
I sometimes (due to mismanagement!) end up with files in a git repo which have had their modes changed, but not their content. This one-liner lets me revert the mode changes, while leaving changed-content files be, so I can commit just the actual changes made.