Commands by bazzargh (4)

  • NB not 'namei -m .', as it slices the path you give it. Show Sample Output

    namei -m $(pwd)
    bazzargh · 2012-07-24 15:27:20 0
  • Search in decimal rather than hex. od dumps the character list, cut to remove offsets, sort -u gives the used characters. seq gives the comparison list, but we need this sorted alphabetically for comm, which does the filtering. I drop to perl to convert back to characters (is there a better way?) and then use od to dump them in a print-safe format. Show Sample Output

    comm -13 <(od -vw1 -tu1 dummy.txt|cut -c9-|sort -u) <(seq 0 127|sort)|perl -pe '$_=chr($_)'|od -c
    bazzargh · 2012-01-09 01:32:20 0
  • A different approach to the problem - maintain a small sorted list, print the largest as we go, then the top 10 at the end. I often find that the find and sort take a long time, and the large file might appear near the start of the find. By printing as we go, I get better feedback. The sort used in this will be much slower on perls older than 5.8. Show Sample Output

    find . -type f|perl -lne '@x=sort {$b->[0]<=>$a->[0]}[(stat($_))[7],$_],@x;splice(@x,11);print "@{$x[0]}";END{for(@x){print "@$_"}'
    bazzargh · 2012-01-08 14:43:43 0
  • the output of svn log is annoying to grep, since it spreads the useful info over multiple lines. This compacts the output down to one line so eg you can grep for a comment and see the rev, date & committer straight away. Updated: MUCH shorter, easier to remember. Now it just replaces newlines with spaces, except on '---' lines. Show Sample Output

    svn log | perl -l40pe 's/^-+/\n/'
    bazzargh · 2011-10-14 16:02:22 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

Remove ( color / special / escape / ANSI ) codes, from text, with sed
Remove ( color / special / escape / ANSI ) codes, from text, with sed Credit to the original folks who I've copied this command from. The diff here is: Theirs: [m|K] Theirs is supposed to remove \E[NUMBERS;NUMBERS[m OR K] This statement is incorrect in 2 ways. 1. The letters m and K are two of more than 20+ possible letters that can end these sequences. 2. Inside []'s , OR is already assumed, so they are also looking for sequences ending with | which is not correct. This : [a-zA-Z] This resolves the "OR" issue noted above, and takes care of all sequences, as they all end with a lower or upper cased letter. This ensures 100% of any escape code 'mess' is removed.

list files in mtime order
Simple but useful; list files in the current directory in mtime order. Useful if you've been working on something and then take a day or two off.

Watch a movie in linux without the X windows system.

Update twitter with Perl
Requires Net::Twitter. Just replace the double quoted strings with the appropriate info.

look for a function reference in a library set

Rotate a pdf by 90 degrees CW

preserve disk; keep OS clean
if you use disk-based swap then it can defeat the purpose of this function.

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"

Edit video by cutting the part you like without transcoding.
Examples: The following will take frames starting at 15.2 seconds for a total of 45.9 seconds: $ mencoder -ss 15.2 -endpos 30.7 -oac copy -ovc copy mymovie.avi -o myeditedmovie.avi Keep in mind -endpos is the total time, i.e. the output video in this is 3 minutes 3 seconds in length: $ mencoder -ss 1 minute -endpos 2 minutes 3 seconds -oac copy -ovc copy mymovie.avi -o myeditedmovie.avi

Changing the terminal title to the last shell command
You can set the previous bash command as the terminal title by this command. Explanation: -trap assigns a command to execute at a given bash signal. -in the $BASH_COMMAND you find the last command -you can set the terminal title with the escape sequence: \e]0;this is the title\007 -to let the echo care about the backslashes give the -e to it Since trap is a built in bash command you find more informatin in 'man bash'for more Source:

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: