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:
This will make a false directory with the same file names as whatever directory you choose. This is wise to use when testing scripts that alter contents, filenames, or move files. I wrote this after an OOPS I made when renaming a directory of JPGs, PNGs, PSDs that were mixed. I recommend this as I lost over 2000 vacation pictures and some graphics I designed for software and web sites. :(
NOTE: This only creates name copies, that data itself is not copied.
Helps if you accidentally deleted files from an svn repo with plain rm and you would like to mark them for svn to delete too.
LC_ALL=C is here to always grep on "differ" whatever your language env.
xargs -n 2 to run gvim -d with 2 arguments
gvim --nofork to use only one instance of gvim
This is a more concise answer to http://blog.commandlinekungfu.com/2011/09/episode-158-old-switcheroo.html in my opinion.
This works more reliable for me ("cut -c 8-" had one more space, so it did not work)
Finds a string in files recursively below the current directory on systems without the "egrep" and its "-r" functionality.
- grep for the word in a files, use recursion (to find files in sub directories), and list only file matches
-| xargs passes the results from the grep command to sed
-sed -i uses a regular expression (regex) to evaluate the change: s (search) / search word / target word / g (global replace)
-sl : show just file names
Videos are found using their MIME type. Thus no need to for an extension for the video file.
This is a efficent version of "jnash" cmd (4086). Thanks for jnash. This cmd will only show video files while his cmd show files having "video" anywhere in path.
Doesn't use shuf, its much faster with "shuf -n4" instead of sort -R
Tells you everything you could ever want to know about all files and subdirectories. Great for package creators. Totally secure too.
On my Slackware box, this gets set upon login:
LS_OPTIONS='-F -b -T 0 --color=auto'
alias ls='/bin/ls $LS_OPTIONS'
which works great.
The original suggestion did not work for me, when operating on folders located on an external mount (ie other than the root device) in Ubuntu. A variation using xargs does the trick.
It can work for message queue, semaphore set or shared memory just changing the parameter.
Escapes spaces in paths.
find . -type f -name '*.wav' -print0 |xargs -0 -P 3 -n 1 flac -V8
will encode all .wav files into FLAC in parallel.
Explanation of xargs flags:
-P [max-procs]: Max number of invocations to run at once. Set to 0 to run all at once [potentially dangerous re: excessive RAM usage].
-n [max-args]: Max number of arguments from the list to send to each invocation.
-0: Stdin is a null-terminated list.
I use xargs to build parallel-processing frameworks into my scripts like the one here: http://pastebin.com/1GvcifYa
If you used to do `vlc /tmp/Flash*`, but no longer can't, this is for you.
For instance, if people have signed your key, this will fetch the signers' keys.
If your version of curl does not support the --compressed option, use
curl -s http://funnyjunk.com | gunzip
curl -s --compressed http://funnyjunk.com
This command can be used to rename all the files with extension .xls( in this case) to .ods files. It can be used for other files with certain extension.