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:
All files in the directory will be renamed replacing every space in the filename by "_" (underline) and converting upper case characters to lower case characters.
e.g. Foo Bar.txt --> foo_bar.txt
This command find which of your zip (or jar) files (when you have lots of them) contains a file you're searching for. It's useful when you have a lot of zip (or jar) files and need to know in which of them the file is archived.
It's most common with .jar files when you have to know which of the .jar files contains the java class you need.
To find in jar files, you must change "zip" to "jar" in the "find" command. The [internal file name] must be changed to the file name you're searching that is archived into one of the zip/jar files.
Before run this command you must step into the directory that contains the zip or jar files.
Converts flac files to mp3 with the same file names in the same directory.
Helps to fix permissions when a user clobbers them in their home directory or elsewhere. Does not rely on file extension, but uses the `file` command for context.
Uses the command ts in order to add a timestamp on each line. This command is provided in the moreutils package on Debian, and you may need libtime-duration-perl to be able to format the date.
When working with jailed environments you need to copy all the shared libraries to your jail environment. This is done by running ldd on a binary which needs to run inside the jail. This command will use the output from ldd to automatically copy the shared libraries to a folder of your choice.
Also lists hidden files, current dir and topdir.
Original submitted version would break if any filenames had whitespaces in them. The command is a Bad Idea anyhow, because you will end up `cat`ing a binary or something else specacularly bad.
Some shell newbies don't know this very handy file management related command so I decided to include it here.
You need to have the "file" package installed.
Rename all mp4 files with crc32 information.
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.
If you make a mess (like I did) and you removed all the executable permissions of a directory (or you set executable permissions to everything) this can help.
It supports spaces and other special characters in the file paths, but it will work only in bash, GNU find and GNU egrep.
You can complement it with these two commands:
1. add executable permission to directories:
find . type d -print0 | xargs -0 chmod +x
2. and remove to files:
find . type d -print0 | xargs -0 chmod -x
Or, in the same loop:
while IFS= read -r -u3 -d $'\0' file; do
case $(file "$file" | cut -f 2- -d :) in
chmod +x "$file"
chmod -x "$file"
esac || break
done 3< <(find . -print0)
Ideas stolen from Greg's wiki: http://mywiki.wooledge.org/BashFAQ/020
Using gentoo prefix portage I got in a situation where some packages did not contain the needed RPATH variable. This command helped me to find out which ones I should recompile
does the -i option open a tmp file?
this method does not.