Commands by cbetti (1)

  • Provides a much cleaner, easier to read output than the closest alternative, ls -1R. This alternative makes it easier to differentiate directories from files: find . -printf '%y %p\n' | perl -ne 'if( m/(\w) (.*)\/(.*)/ ) { $t = $1; $p = $2; $f = $3; $t =~ s/[^d]/ /; $p =~ s/[^\/]/ /g; $p =~ s/\//|/g; print "$t $p/$f\n"; } elsif( m/(\w) (.*)/ ) { print "$1 $2\n"; } else { print "error interpreting: \"$_\"\n"; }' Show Sample Output


    0
    find . -printf '%p\n' | perl -ne 'if( m/(.*)\/(.*)/ ) { $p = $1; $f = $2; $p =~ s/[^\/]/ /g; $p =~ s/\//|/g; print "$p/$f\n"; } elsif( m/(.*)/ ) { print "$1\n"; } else { print "error interpreting: \"$_\"\n"; }'
    cbetti · 2012-04-24 19:51:00 3

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

Find all files of a type and copy them elsewhere while keeping intact their full directory structure using find and cpio
.flac is the filetype. /Volumes/Music/FLAC is the destination.

Use Linux coding style in C program
put "-linux" option into $HOME/.indent.pro to make it default

Check whether IPv6 is enabled
Checks whether IPv6 is enabled system-wide by reading from procfs.

Remove any RPMs matching a pattern
This should be an option to rpm, but isn't. I wind up using it a lot because I always forget the full name of the packages I want to delete.

How To Get the Apache Document Root

generate a telephone keypad
seems a useless command ...

Text graphing ping output filter
Nasty perl one-liner that provides a sparkline of ping times. If you want a different history than the last 30, just put that value in. It (ab)uses unicode to draw the bars, inspired by https://github.com/joemiller/spark-ping . It's not the most bug-free piece of code, but what it lacks in robustness it makes up for in capability. :) If anyone has any ideas on how to make it more compact or better, I'd love to hear them. I included a ping to google in the command just as an example (and burned up 10 chars doing it!). You should use it with: $ ping example.com | $SPARKLINE_PING_COMMAND

scroll file one line at a time (w/only UNIX base utilities)
usage examples ls largedir |rd lynx -dump largewebsite.com |rd rd < largelogfile

Reuse last parameter
Reuse the last parameter of the previous command line

Create a file server, listening in port 7000
At client side: tar c myfile | nc localhost 7000 ##Send file myfile to server tar c mydir | nc localhost 7000 ## Send directory mydir to server


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: