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:
List the full path of some files.
You can add ".*" on the end if you want to display hidden files.
Better awk example, using only mplayer, grep, cut, and awk.
Parses /etc/group to "dot" format and pases it to "display" (imagemagick) to show a usefull diagram of users and groups (don't show empty groups).
Converts a number of bytes provided as input, to a human readable number.
Converts IP octets to hex using printf command. Useful for generating pxeboot aliases in the pxelinux.cfg folder.
poorman's ifstat using just sh and awk. You must change "eth0" with your interface's name.
when you can do it , avoid pipe
I find it useful when I want to add another crontab entry and I need to specify the appropriate PATH.
I give ''whichpath'' a list of programs that I use inside my script and it gives me the PATH I need to use for this script.
''whichpath'' uses associative array, therefore you should have Bash v4 in order to run it.
See sample output.
WIDTHL=10 and WIDTHR=60 are setting the widths of the left and the right column/bar. BAR="12345678" etc. is used to create a 80 char long string of "="s. I didn't know any shorter way.
If you want to pipe results into it, wrap the whole thing in ( ... )
I know that printing bar graphs can be done rather easily by other means. Here, I was looking for a Bash only variant.
Calc the rough time from Twitter. Now with leading Zeroes.
usage: mem memcache-command [arguments]
where memcache-command might be:
exptime argument is set to 0 (no expire)
flags argument is set to 1 (arbitrary)
also works in vim
Among other things, this allows the sorting of comment descriptions and command lines retrieved as text from CommandLineFu.com.
rename file name with fixed length nomeric format pattern
Replace service --status-all 2>&1 by service --status-all 2>/dev/null to hide all services with the status [ ? ]
Watch the temperatures of your CPU cores in real time at the command line. Press CONTROL+C to end.
GORY DETAILS: Your computer needs to support sensors (many laptops, for example, do not). You'll need to install the lm-sensors package if it isn't already installed. And it helps to run the `sensors-detect` command to set up your sensor kernel modules first. At the very end of the sensors-detect interactive shell prompt, answer YES to add the new lines to the list of kernel modules loaded at boot.
This command will delete all branches in your git repository other than next and master. I use this to cleanup my git repos after making multiple branches and merging them back into next. It's much faster than individually deleting each expired branch using:
git branch -D <branch_name>
this leaves the cursor at the bottom of the terminal screen, where your eyes are.
ctrl-l moves it to the top, forcing you to look up.
A shorter version
The first argument is the interpreter for your script, the second argument is the name of the script to create.