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:
Written on OSX after `brew install unrar coreutils`; presumably works on other unices with minimal modifications.
Didn't test rars that actually have paths in them, just "flat" files. Won't include files in the rar starting with a dot.
compress directory archive with xz compression, if tar doesn't have the -J option (OSX tar doesn't have -J)
Compress files or a directory to xz format. XZ has superior and faster compression than bzip2 in most cases. XZ is superior to 7zip format because it can save file permissions and other metadata data.
If you vim a compressed file it will list all archive content, then you can pickup any of them for editing and saving. There you have the modified archive without any extra step. It supports many file types such as tar.gz, tgz, zip, etc.
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.
This will list the files in a directory, then zip each one with the original filename individually.
video1.wmv -> video1.zip
video2.wmv -> video2.zip
This was for zipping up large amounts of video files for upload on a Windows machine.
- all zips are in current folder
- FILENAME is file name that should be subsitute in all zips (new version of this file is in current folder)
This zips a directory recursively but excludes some directories within the zipped directory. Useful for excluding .svn and .git directories, or compilation targets.
Simplicity tends to win out on commandlinefu.com Also, why type multiple filenames when range operators work too. Saves finger abuse and time and reduces the chances for mistakes.
Assuming you have a multi-part archive like "archive.zip archive.z01 archive.z02 ...", unzip will not handle these correctly. If you "fix" the parts into one big file with zip -F before, it works.
Better tool for exporting git's repository is Git itself!
If like me you do a lot of front-end coding and you have a lot of clients that asks you some little modifications, then you send the modifications back to them in a zip file while ignoring the .git folder and .gitignore file, then copy this zip into your dropbox and send it back to them. They find out a new bug so, rince and repeat? You get the picture. It can be quite tedious.
Using 7z to create archives is OK, but when you use tar, you preserve all file-specific information such as ownership, perms, etc. If that's important to you, this is a better way to do it.