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:
as commented by Urk...
Rotates log files with "gz"-extension in a directory for 7 days and enumerates the number in file name.
i.e.: logfile.1.gz > logfile.2.gz
I needed this line due to the limitations on AIX Unix systems which do not ship with the rename command.
find pictures recursively in a specified folder and renames the file name to originalname_containingfoldername.jpg
Recursively find php files and replace tab characters with spaces.
"\*.php" -- replace this with the files you wish to find
"expand" -- replace tabs with spaces (use "unexpand" to replace spaces with tabs)
"-t4" -- tabs represent 4 spaces
Note: The IFS="" in the middle is to prevent 'read' from eating leading/trailing whitespace in filenames.
Recursively changes every file case to lowercase
Renames files eliminating suffix, in this case everything after "-" is cutted. Just change "-" with the character you need.
If you want to turn a Git repo into the origin that folks can push to, you should make it a bare repository. See: http://stackoverflow.com/questions/2199897/git-convert-normal-to-bare-repository
If you have a folder with thousand of files and want to have many folder with only 100 file per folder, run this.
It will create 0/,1/ etc and put 100 file inside each one.
But find will return true even if it don't find anything ...
just an alternative to #7818
I don't like TABs in sources files because in case of mixture of TABs and spaces they looks in different editors. Even worse mixing TABs and spaces could be a problem when you use Python.
i use this after ripping internet radio streams to number the files as they originally played (even though streamripper can do this with -q).
to number other types of files, or all files, just change the *mp3. to rename directories only you could use
... ls -lt | grep ^d | cut -d ":" -f2 | cut -d " " -f2- | while read ...
Maybe simpler, but again, don't know how it will work with space in filename.
(Changed to "bartonskis" suggestion.)
Robust means of moving all files up by a directory. Will handle dot files, filenames containing spaces, and filenames with almost any printable characters. Will not handle filenames containing a single-quote (but if you are moving those, it's time to go yell at whoever created them in the first place).
Same thing using bash built-in features instead of a sub-shell.
Batch rename extension of all files in a folder, in the example from .txt to .md
Useful if you have a list of images called 1 2 3 4 and so on, you can adapt it to rewrite it as 4 (in this example) 0-padded number.
If you don't escape the - of the filename, you will get the command interpreting it as a parameter, returning (in the best case) an error.
Avoid clobbering files by either overwriting due to name collisions or by assuming the command worked and deleting the target directory.
I think this is less resource consuming than the previous examples