Commands by aikikode (2)

  • This command will allow to search for duplicate processes and sort them by their run count. Note that if there are same processes run by different users you'll see only one user in the result line, so you'll need to do: ps aux | grep <process> to see all users that run this command. Show Sample Output

    ps aux | sort --key=11 | uniq -c -d --skip-fields=10 | sort -nr --key=1,1
    aikikode · 2011-07-19 07:11:29 0
  • After executing a command with multiple arguments like cp ./temp/ ~/prog/ you can paste any argument of the previous command to the console, like ls -l ALT+1+. is equivalent to ls -l ./temp/ ALT+0+. stands for command itself ('ls' in this case) Simple ALT+. cycles through last arguments of previous commands.

    <ALT>+<.> or <ALT>+<NUM>+<.> or <ALT>+<NUM>,<ALT>+<.>
    aikikode · 2011-03-01 17:41:08 0

What's this? 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

bash: hotkey to put current commandline to text-editor
* in bash-shell You can capture the current commandline to a text-editor: * simply press: CTRL+x+e * Your current commandline will pe put into Your default text-editor (export EDITOR=vim)

Use last argument of last command
Bash shortcut to work with the last argument of your last command

Search google and show only urls
Get the first 10 google results form a querry, but showing only the urls from the results. Use + to search diferent terms, ex: commandlinefu+google .

Resize photos without changing exif
To resize photos without changing exif datas, pretty cool for gps tagging. (Require ImageMagick)

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Benchmark SQL Query
Benchmark a SQL query against MySQL Server. The example runs the query 10 times, and you get the average runtime in the output. To ensure that the query does not get cached, use `RESET QUERY CACHE;` on top in the query file.

Print a row of characters across the terminal
Pure Bash This will print a row of characters the width of the screen without using any external executables. In some cases, COLUMNS may not be set. Here is an alternative that uses tput to generate a default if that's the case. And it still avoids using tr. $ printf -v row "%${COLUMNS:-$(tput cols)}s"; echo ${row// /#} The only disadvantage to either one is that they create a variable.

pretend to be busy in office to enjoy a cup of coffee
Create a progress dialog with custom title and text using zenity.

Create POSIX tar archive
tar(1) and cpio(1) are not fully platform agnostic, although their file formats are specified in POSIX.1-2001. As such, GNU tar(1) might not be able to extract a BSD tar(1) archive, and ivce versa. pax(1) is defined in POSIX.1-2001. To extract an archive: $ pax -rf archive.tar

find out how many days since given date
You can also do this for seconds, minutes, hours, etc... Can't use dates before the epoch, though.

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.


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: