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:
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 ...
can also be invoked as 'exipick -zi | exim -dM' if you do not need/want the delay between flushes.
No need for further filedes or substitution for splitting. Simply use read a b
[Update! Thanks to a tip from ioggstream, I've fixed both of the bugs mentioned below.]
You, yes, 𝙔𝙊𝙐, can be the terror of the Internet! Why use normal, boring bullet points in your text, when you could use a ROTATED HEAVY BLACK HEART BULLET (❥)!? (Which would also be an awesome band name, by the way).
This script makes it easy to find unusual characters from the command line. You can then cut and paste them or, if you're using a GTK application, type Control+Shift+U followed by the code point number (e.g., 2765) and then a SPACE.
USAGE: Put this script in a file (I called mine "ugrep") and make it executable. Run it from the command line like so,
The output will look like this,
☙ U+2619 REVERSED ROTATED FLORAL HEART BULLET
♡ U+2661 WHITE HEART SUIT
♥ U+2665 BLACK HEART SUIT
❣ U+2763 HEAVY HEART EXCLAMATION MARK ORNAMENT
❤ U+2764 HEAVY BLACK HEART
❥ U+2765 ROTATED HEAVY BLACK HEART BULLET
❦ U+2766 FLORAL HEART
❧ U+2767 ROTATED FLORAL HEART BULLET
⺖ U+2E96 CJK RADICAL HEART ONE
⺗ U+2E97 CJK RADICAL HEART TWO
⼼ U+2F3C KANGXI RADICAL HEART
You can, of course, use regular expressions. For example, if you are looking for the "pi" symbol, you could do this:
REQUIREMENTS: Although this is written in Bash, it assumes you have Perl installed because it greps through the Perl Unicode character name module (/usr/lib/perl5/Unicode/CharName.pm). Note that it would not have made more sense to write this in Perl, since the CharName.pm module doesn't actually include a subroutine for looking up a character based on the description. (Weird.)
BUGS: In order to fit this script in the commandlinefu limits, a couple bugs were added. ① Astral characters beyond the BMP (basic multilingual plane) are not displayed correctly, but see below. ② Perl code from the perl module being grepped is sometimes extraneously matched.
MISFEATURES: Bash's printf cannot, given a Unicode codepoint, print the resulting character to the terminal. GNU's coreutils printf (usually "/usr/bin/printf") can do so, but it is brokenly pedantic about how many hexadecimal digits follow the escape sequence and will actually die with an error if you give the wrong number. This is especially annoying since Unicode code points are usually variable length with implied leading zeros. The CharNames.pm file represents BMP characters as 4 hexits, but astral characters as 5. In the actual version of this script that I use, I've kludged around this misfeature by zero-padding to 8 hexits like so,
/usr/bin/printf "\U$(printf "%08x" 0x$hex)"
TIP 1: The author recommends "xsel" for command line cut-and-paste. For example,
ugrep biohazard | xsel
TIP 2: In Emacs, instead of running this command in a subshell, you can type Unicode code points directly by pressing Control-Q first, but you'll likely want to change the default input from octal to hexadecimal. (setq read-quoted-char-radix 16).
TIP 3: Of course, if you're using X, and you want to type one of the more common unusual characters, it's easiest of all to do it with your Compose (aka Multi) key. For example, hitting [Compose] <3 types ♥.
in case you run some command in CLI and would like to take read strerr little bit better, you can use the following command. It's also possible to grep it if necessary....
make, find and a lot of other programs can take a lot of time. And can do not. Supppose you write a long, complicated command and wonder if it will be done in 3 seconds or 20 minutes. Just add "R" (without quotes) suffix to it and you can do other things: zsh will inform you when you can see the results.
You can replace zenity with other X Window dialogs program.
Like 7171, but fixed typo, uses fewer variables, and even more cryptic!
This command finds all of the functions defined in any shell script you specify including .bashrc
Should be a bit more portable since echo -e/n and date's -Ins are not.
This version works across on all POSIX compliant shell variants.
Returns true if user presses the key.
Use it like
Confirm "Continue" && do action
This is useful when watching a log file that does not contain timestamps itself.
If the file already has content when starting the command, the first lines will have the "wrong" timestamp when the command was started and not when the lines were originally written.
Increase the modification date for the files selected with the find command.
gunzip all .gz file in current dir
Listens for events in the directory. Each created file is displayed on stdout. Then each fileline is read by the loop and a command is run.
This can be used to force permissions in a directory, as an alternative for umask.
The given example collects output of the tail command: Whenever a line is emitted, further lines are collected, until no more output comes for one second. This group of lines is then sent as notification to the user.
You can test the example with
logger "First group"; sleep 1; logger "Second"; logger "group"
ls largedir |rd
lynx -dump largewebsite.com |rd
rd < largelogfile
Say you want to time how long a task you're performing takes. Start this simple timer and you're done!