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:
rm -rf .* matches ".." and thus one goes up a level and wipes out more than intended.
In bash, .??* safely accomplishes what one intends - remove those .files
The ? matches most characters except "/", thus .?? does not match ../ and so one is safe.
Remove all arquives except the list.
Can't have space between the commas.
Bash method to remove all files but "abc".
It would be 'rm *~abc' in Zsh.
-depth argument will cause find to do a "depth first" tree search, this will eliminate the "No such file or directory" error messages
expands through shell and not find
but may hits the limit of max argument size for rm
(thus: for f in **/*.htm;do rm $f;done
but then I prefer the find command ;)
This is for zsh with extended globbing.
An alternative which uses the advanced zsh globbing (pattern matching)
Really, you deserve whatever happens if you have a whitespace character in a file name, but this has a small safety net. The truly paranoid will use '-i'.
Please be careful while executing the following command as you don?t want
to delete the files by mistake. The best practice is to execute the same
command with ls ?l to make sure you know which files will get deleted when
you execute the command with rm.
This will search all directories and ignore the CVS ones. Then it will search all files in the resulting directories and act on them.
This is a slight variation of an existing submission, but uses regular expression to look for files instead. This makes it vastly more versatile, and one can easily verify the files to be kept by running ls | egrep "[REGULAR EXPRESSION]"
Remove all empty directories below the current directory. If directories become empty as the results of this, remove those too.
it will remove everything except the file names matching you can use also use wildcards
Remove everything except that file with shell tricks inside a subshell to avoid changes in the environment.
This is an useful command for when your OS is reporting less free RAM than it actually has. In case terminated processes did not free their variables correctly, the previously allocated RAM might make a bit sluggis over time.
This command then creates a huge file made out of zeroes and then removes it, thus freeing the amount of memory occupied by the file in the RAM.
In this example, the sequence will free up to 1GB(1M * 1K) of unused RAM. This will not free memory which is genuinely being used by active processes.
Remove everything in current directory except files starting with "ca".
avoid rm to be recursive until you complete the command: put the -rf at the end!
Deletes empty directories and prints an error if directory is not empty.