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.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
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:
*I run this with byobu as as a custom status bar entry that runs every 10 seconds by putting it in a script here:
.byobu/bin/10_update_windows
There's no output to stdout, so nothing is displayed on the status bar.
*Presumes that #{pane_title} is set to the hostname or prompt containing the host name. In my case, it's in this format:
$USER@$HOSTNAME:$PWD
The sed commands may need to be modified if your pane_title is different.
*If you want to strip out a common part of a hostname, add the following before '| uniq'
-e 's/[COMMON PART]//'
I use that to strip out the domain of the servers I connect to, leaving the subdomain.
Use if you want to include untrusted literal strings in your grep regexes.
I use it to list all mounts below a directory:
dir=/mnt/gentoo; cat /proc/mounts |awk '{print $2}' |egrep "^$(egrep_escape "$dir")(/|$)"
/mnt/gentoo
/mnt/gentoo/proc
/mnt/gentoo/sys
/mnt/gentoo/dev
/mnt/gentoo/home
Works even if $dir contains dangerous characters (e.g. comes from a commandline argument).
You can execute this inside an editor to get all the fields inside your buffer and do the magic, really usefull when your tables contain a giant list of fields.
This version combines the best of the other suggestions and adds these features:
1. It scans a /16 subnet
2. It is very fast by running the ping commands in the background, running them in parallel.
3. Does not use the "-W" option as that's not available in older ping versions (I needed this for OS X 10.5)
It executes commands as arguments to ssh, avoiding problematic shell expansions, without the need of writing the commands in question to a temporary file, just reading them from STDIN.
This command clones an image three times and creates a 'tile' image that can be used for a repeating pattern wallpaper. Add 'rm $f $of $off' to the end for cleanup (command was too long to submit with it).
See this link for an example: http://meathive.deviantart.com/art/Easy-Photography-Hack-314846774
added echo "### Crontabs for $user ####"; to make clear whose crontab is listed.
added echo "### Crontabs for $user ####"; to make clear whose crontab is listed.
Create a bash function for easy reference
webPassword()
{
echo $1 $2 | md5sum | awk '{print substr($0,0,10)}'
}
alias webpwd=webPassword
Use like this.
webpwd www.commandlinefu.com MyPetNameHere
This command allows you to revert every modified file one-by-one in a while loop, but also after "echo $file;" you can do any sort of processing you might want to add before the revert happens.
I just found another use for the builtin ':' bash command. It increments counters for me in a loop if a certain condition is met...
: [arguments]
No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned.
-r recursively
-Z zero byte after each file name instead of the usual newline
-l only filenames
create and md5 sum of your password without it showing up in your terminal or history.
Afterwards we overwrite the $p variable (thx to bazzargh)
Pros: Works in all Windows computers, most updated and compatible command.
Cons: 3 liner
Replace fcisolutions.com with your site name.
This command takes a few changes to get to the file format, but once you have that, you're good to go. Set your environment variables and then change the text "front" and "back" to whatever you're files start and end with. You'll end up with some easily sort-able files.