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:
Everyone wants to take spaces out of filenames. Forget that. I want to put them back in. We've got tools and filesystems that support spaces, they look better, so I'm going to use them.
Because of how find works I find I need to run this multiple times, if it's renaming subdirs. But it can be re-run without issues.
I got this version of the command from a comment in this underscore-generating command. http://www.commandlinefu.com/commands/view/760/find-recursively-from-current-directory-down-files-and-directories-whose-names-contain-single-or-multiple-whitespaces-and-replace-each-such-occurrence-with-a-single-underscore. All I did was change the regex.
A much shorter version of this command.
This command does the following:
- converts any sequence of multiple spaces/tabs to one space only
- completely removes any space(s)/tab(s) at the end of each line
(If spaces and tabs are mixed in a sequence i.e. [tab][tab][space][tab], you have to execute this command twice!)
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.
The sample command searches for PHP files replacing tabs with spaces.
-u NONE # don't use vimrc
one may pass
Look at this http://susepaste.org/69028693 also
Using the double dash before the source and target makes the command work fine with weird filenames.
ls -Q will show the filenames in quotes. xargs -p rm will print all the filenames piped from ls -Q and ask for confirmation before deleting the files.
without the -Q switch, if we have spaces in names, then the files won't be deleted.