Commands by mathias (5)

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

dump a single table of a database to file

Use -t when using find and cp
-t, --target-directory=DIRECTORY (copy all SOURCE arguments into DIRECTORY).

tail, with specific pattern colored

Directory Tree

Easy file sharing from the command line using transfer.sh
Requires: curl xsel access to the internet(http://transfer.sh) This is an alias utilizing the transfer.sh service to make sharing files easier from the command line. I have modified the alias provided by transfer.sh to use xsel to copy the resulting URL to the clipboard. The full modified alias is as follows since commandlinefu only allows 255 characters: transfer() { if [ $# -eq 0 ]; then echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" |xsel --clipboard; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" |xsel --clipboard ; fi; xsel --clipboard; }

Find dead symbolic links
-L tells find to follow symbolic links, so -type l will only return links it can't follow (i.e., those that are broken).

Get your outgoing IP address
Instead of opening your browser, googling "whatismyip"... Also useful for scripts. dig can be found in the dnsutils package.

Find processes stuck in dreaded "D" state aka IO Wait
Lots of fun to run on nfs clients when the server or network connection is having issues

Search for a string inside all files in the current directory
ack seeks for , list all found files and display everything in nice colors. Look for it in http://betterthangrep.com/

Load your [git-controlled] working files into the vi arglist.
Branch name may be substituted, of course.


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: