Commands by erichamion (1)

  • This requires a version of GNU find that supports the -exec {} + action, but it seems more straightforward than the versions already posted. Show Sample Output

    find . -type f -exec ls -shS {} + | head -10
    erichamion · 2012-07-28 17:21:46 4

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

tail: watch a filelog
-f file(s) to be monitorized -n number of last line to be printed on the screen in this example, the content of two files are displayed

Display the list of all opened tabs from Firefox via a python one-liner and a shell hack to deal with python indentation.
You have to do that before : $ cd ~/.mozilla/firefox/ Require bash. If you use something else, you may use $ echo | python Forked from ArkSeth python script.

prints line numbers

remove comments (even those starting with spaces), empty lines (even those containing spaces) in one grep command
useful for discarding even those comments which start with blanks or those empty lines which contain blanks

Monitor a file with tail with timestamps added

Debug how files are being accessed by a process
Instead of looking through `lsof` results, use inotifywait!

colorize comm output
It just colorizes the line based on if it has 0, 1 or 2 tabs at the beginning of the line. Won't work so well if lines already begin with tabs (too bad comm doesn't have an option to substitute \t for something else). Don't forget comm needs input files to be sorted. You can use a shortcut like this with bash: comm

Change user within ssh session retaining the current MIT cookie for X-forwarding
When you remotely log in like "ssh -X userA:host" and become a different user with "su UserB", X-forwarding will not work anymore since /home/UserB/.Xauthority does not exist. This will use UserA's information stored in .Xauthority for UserB to enable X-forwarding. Watch for details.

Search recursively to find a word or phrase in certain file types, such as C code
I have a bash alias for this command line and find it useful for searching C code for error messages. The -H tells grep to print the filename. you can omit the -i to match the case exactly or keep the -i for case-insensitive matching. This find command find all .c and .h files

(DEBIAN-BASED DISTROS) Find total installed size of packages given a search term
Replace \-dev with whatever you wanna search for

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: