Commands by hk0i (1)

  • Sometimes you unzip a file that has no root folder and it spews files all over the place. This will clean up all of those files by deleting them. Show Sample Output


    0
    unzip -l filename.zip |awk '{ if($4 != "Name" && $4 != "----") print $4}'|xargs -t rm -rf {}
    hk0i · 2011-10-20 18:54:15 0

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

Downsample mp3s to 128K
This will lower the quality of mp3 files, but is necessary to play them on some mobile devices.

list files recursively by size

Show webcam output
Show the webcam output with mplayer.

easily strace all your apache processes
Will open strace on all apache process, on systems using sbin/apache (debian) or sbin/httpd (redhat), and will follow threads newly created.

Add calendar to desktop wallpaper
Add calendar to desktop wallpaper , mess with the coordinates to place where you like

Print out your hard drive to a jet-direct compatible printer.
Where 192.168.1.2 is a printer with jet-direct. No, I don't suggest this as a backup method.

aptitude easter eggs
this is a reference to Antoine de St. Exupery's "The Little Prince"

Set laptop display brightness
Run as root. Path may vary depending on laptop model and video card (this was tested on an Acer laptop with ATI HD3200 video). $ cat /proc/acpi/video/VGA/LCD/brightness to discover the possible values for your display.

connects to a serial console
cu (call UNIX) establishes a full-duplex connection to another machine (*BSD) using a serial console. It becames more useful than screen if you have to send a BREAK signal. using cu just type "~#". $man cu http://www.openbsd.org/cgi-bin/man.cgi?query=cu&apropos=0&sektion=0&manpath=OpenBSD+Current&arch=i386&format=html

List all duplicate directories
Very quick! Based only on the content sizes and the character counts of filenames. If both numbers are equal then two (or more) directories seem to be most likely identical. if in doubt apply: $ diff -rq path_to_dir1 path_to_dir2 AWK function taken from here: http://stackoverflow.com/questions/2912224/find-duplicates-lines-based-on-some-delimited-fileds-on-line


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: