Hide

What's this?

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/

Get involved!

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.

Hide

Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands tagged stderr from sorted by
Terminal - Commands tagged stderr - 7 results
cat aaaaaa 2>&-
<command> 2> <file>
mycommand 2> >(while read line; do echo -e "\e[01;31m$line\e[0m"; done)
2010-12-30 21:42:42
User: confiq
Functions: echo read
Tags: color stderr
19

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....

strace -e write=1,2 -p $PID 2>&1 | sed -un "/^ |/p" | sed -ue "s/^.\{9\}\(.\{50\}\).\+/\1/g" -e 's/ //g' | xxd -r -p
2010-10-06 19:37:39
User: glaudiston
Functions: sed strace
3

Useful to recover a output(stdout and stderr) "disown"ed or "nohup"ep process of other instance of ssh.

With the others options the stdout / stderr is intercepted, but only the first n chars.

This way we can recover ALL text of stdout or stderr

exec 2>&1
2010-08-05 08:24:18
User: redy
Functions: exec
9

You have a script where =ALL= STDERR should be redirected to STDIN and you don't want to add "2>&1" at the end of each command...

E.G.:

ls -al /foo/bar 2>&1

Than just add this piece of code at the beginning of your script!

I hope this can help someone. :)

strace -ff -e write=1,2 -s 1024 -p PID 2>&1 | grep "^ |" | cut -c11-60 | sed -e 's/ //g' | xxd -r -p
2010-04-23 16:22:17
User: systemj
Functions: cut grep sed strace
10

similar to the previous command, but with more friendly output (tested on linux)

strace -ff -e trace=write -e write=1,2 -p SOME_PID