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:
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.
The first argument is the interpreter for your script, the second argument is the name of the script to create.
The exported TSV file of Google Adwords' first five columns are text, they usually should collapse into one cell, a multi-line text cell, but there is no guaranteed way to represent line-break within cells for .tsv file format, thus Google split it to 5 columns.
The problem is, with 5 columns of text, there are hardly space to put additional fields while maintain printable output.
This script collapses the first five columns of each row into one single multi-line text cell, for console output or direct send to printer.
The exported TSV file of Google Adwords' first five columns are text, they usually should collapse into one cell, a multi-line text cell, but there is no guaranteed way to represent line-break within cells for .tsv file format, thus Google split it to 5 columns.
The problem is, with 5 columns of text, there are hardly space to put additional fields while maintain printable output.
This script collapses the first five columns of each row into one single multi-line text cell. new line character we use Line-Separator character (unicode U+2028), which is respected by gnumeric. It outputs a new .tsv file that opens in gnumeric.
This is a different version from my original command: Console clock -- Beautiful (http://www.commandlinefu.com/commands/view/7902/console-clock-beautiful )
This one uses Boxes and Figlet.
To install the dependencies on Ubuntu, type in:
sudo apt-get install boxes figlet
To install the dependencies on Debian, type in:
aptitude install boxes figlet
This will show a console clock with Figlet.
This is with the Star Wars font.
Change the -f option to anything else.
Notice: You need Figlet installed for this to work.
To install Figlet on Ubuntu, type in:
sudo apt-get install figlet
To install Figlet on Debian, type in:
aptitude install figlet
This command will automatically clear the old clock time, and show the new clock time.
It will also slightly format it.
remove all carriage return of a given file (or input, if used with | ) and replace them with a space (or whatever character is after %s)
function for .bash_aliases that prints a line of the character of your choice in the color of your choice across the terminal.
Default character is "=", default color is white.
Shorter and more straightforward.
Also in perl:
perl -e 'print join(":", map { sprintf "%0.2X",rand(256) }(1..6))."\n"'
Alias to produce a list of all subdir sizes in current dir, in reverse order and human readable units. du is executed only once. Remove the slash after the asterisk to include files.
displays current time in "binary clock" format
(loosely) inspired by: http://www.thinkgeek.com/homeoffice/lights/59e0/
"Decoding":
8421
.... - 1st hour digit: 0
*..* - 2nd hour digit: 9 (8+1)
.*.. - 1st minutes digit: 4
*..* - 2nd minutes digit: 9 (8+1)
Prompt-command version:
PROMPT_COMMAND='echo "10 i 2 o $(date +"%H%M"|cut -b 1,2,3,4 --output-delimiter=" ") f"|dc|tac|xargs printf "%04d\n"|tr "01" ".*"'
Should be a bit more portable since echo -e/n and date's -Ins are not.
So your boss wants to know how much memory has been assigned to each virtual machine running on your server... here's how to nab that information from the command line while logged in to that server
Useful if you have a list of images called 1 2 3 4 and so on, you can adapt it to rewrite it as 4 (in this example) 0-padded number.
When you have different digital cameras, different people, friends and you want to merge all those pictures together, then you get files with same names or files with 3 and 4 digit numbers etc. The result is a mess if you copy it together into one directory.
But if you can add an offset to the picture number and set the number of leading zeros in the file name's number then you can manage.
OFFS != 0 and LZ the same as the files currently have is not supported. Or left as an exercise, hoho ;)
I love NF="${NF/#+(0)/}",it looks like a magic bash spell.