All commands (14,187)

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

get stdout to variable and stdout at sametime
Sometimes you want to write the script output to stdout but you need to send it to email. If you use: $ var="$( ls / )"; $ echo -e "$var"; works but, you need to wait the script terminate to bufferize then print the output var; With this way, you can use/work/print the output before the variable receive all the output content, then after it you can use the variable for anything else, like send email.

Print all /etc/passwd lines with duplicated uid
Prints all the lines in /etc/passwd belonging to users with a duplicated uid. It also adds the hostname to the beginning of the line. It's been tested in AIX, Solaris and Linux.

Getting information about model no. of computer
This command gives a model information of a computer. Also useful in determining the host is a VM machine or actual physical machine.

Mortality Countdown
watch the seconds of your life tick away - replace YYYY-mm-dd HH:MM:ss w/ your birthtime.

Recursive Line Count
We use `-not -name ".*"` for the reason we must omit hidden files (which unnecessary). We can only show up total lines like this: $ find * -type f -not -name ".*" | xargs wc -l | tail -1

lazy SQL QUERYING
This is regarding the command 8263 using an alias to fill in command line options for psql. You can actually just type 'psql'. In order for that to work, you want to set environment variables PGDATABASE, PGHOST, PGUSER, and (except you're using the default) PGPORT. Also, you can add a line "host:port:dbname:user:password" (asterisk ok in some columns) to your ~/.pgpass file. Finally, if you don't like the aligned columns, you can add the line "\pset format unaligned" to your ~/.psqlrc file.

Display the history and optionally grep
Place this in your .bash_profile and you can use it two different ways. If you issue 'h' on its own, then it acts like the history command. If you issue: $ h cd Then it will display all the history with the word 'cd'

Get Futurama quotations from slashdot.org servers

Find files changed between dates defined by ctime of two files specified by name
This command finds all the files whose status has changed between the ctime of the older and newer . Very useful if you can see from an ls listing a block of consecutive files you want to move or delete, but can't figure out exactly the time range by date.

Converts all windows .URL shortcuts in a directory to linux (gnome) .desktop shortcuts


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: