All commands (13,033)

  • Sort .avi movies by time length, print the longest first, and so on... Show Sample Output


    1
    for i in *.avi; do echo -n "$i:";totem-gstreamer-video-indexer $i | grep DURATION | cut -d "=" -f 2 ; done | sort -t: -k2 -r
    iadbungler · 2009-11-09 02:59:53 0
  • Stops when the (last) dd process exits.


    -2
    while killall -USR1 dd; do sleep 5; done
    Mikachu · 2009-11-09 00:27:33 0
  • If you leave out the block size it defaults to 512 bytes. I set it to 16 Megabytes and it was much faster...


    -3
    dd if=/dev/zero of=/dev/hda bs=16M
    Clopnixus · 2009-11-09 00:13:35 0
  • Useful if you have copied files from an OS without a permission structure (for example, DOS) and you need to disable all executable files but want to be able to descend into your directories.


    1
    find . ! -type d -exec chmod -x {}\;
    drashkeev · 2009-11-08 21:27:08 1
  • With this form you dont need to cut out target directory using grep/sed/etc.


    4
    (ls; mkdir subdir; echo subdir) | xargs mv
    mechmind · 2009-11-08 11:40:55 5
  • This is a cool trick to view the contents of the file on /dev/pts/0 (or whatever terminal you're using), and also send the contents of that file to another program by way of an unnamed pipe. All the while, you've not bothered saving any extra data to disk, like you might be tempted to do with sed or grep to filter output.


    2
    cat /path/to/some/file.txt | tee /dev/pts/0 | wc -l
    atoponce · 2009-11-07 22:24:28 2
  • This function uploads images to http://omploader.org and then prints out the links to the file. Some coloring can also be added to the command with: ompload() { curl -F file1=@"$1" http://omploader.org/upload|awk '/Info:|File:|Thumbnail:|BBCode:/{gsub(/<[^<]*?\/?>/,"");$1=$1;sub(/^/,"\033[0;34m");sub(/:/,"\033[0m:");print}';} Show Sample Output


    8
    ompload() { curl -# -F file1=@"$1" http://ompldr.org/upload|awk '/Info:|File:|Thumbnail:|BBCode:/{gsub(/<[^<]*?\/?>/,"");$1=$1;print}';}
    eightmillion · 2009-11-07 20:56:52 1

  • 4
    mpg123 `curl -s http://blip.fm/all | sed -e 's#"#\n#g' | grep mp3$ | xargs`
    torrid · 2009-11-07 14:48:01 2

  • 14
    wget -q -O - `youtube-dl -b -g $url`| ffmpeg -i - -f mp3 -vn -acodec libmp3lame -| mpg123 -
    torrid · 2009-11-07 13:45:13 7
  • This version of tweet() doesn't require you to put quotes around the body of your tweet... it also prompts you for password. It will still barf on a '!' character.


    7
    tweet () { curl -u UserName -d status="$*" http://twitter.com/statuses/update.xml; }
    bartonski · 2009-11-07 06:54:02 0

  • -1
    grep -c '^From ' mbox_file
    drewk · 2009-11-07 03:31:05 0

  • 6
    read -sn 1 -p 'Press any key to continue...';echo
    arcege · 2009-11-07 03:05:21 1
  • This works on some other version of read.


    -4
    echo -n "Press any key to continue..." && read
    matthewbauer · 2009-11-06 22:49:46 2
  • A shell function using perl to easily convert Unix-time to text. Put in in your ~/.bashrc or equivalent. Tested on Linux / Solaris Bourne, bash and zsh. using perl 5.6 and higher. (Does not require GNU date like some other commands) Show Sample Output


    1
    utime(){ perl -e "print localtime($1).\"\n\"";}
    MoHaG · 2009-11-06 12:58:10 0

  • -4
    wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
    sanjaygoel · 2009-11-06 10:18:26 0
  • That makes a function you can put in your ~/.bashrc to run it when you need in any term with an IP as argument Show Sample Output


    3
    GeoipLookUp(){ curl -A "Mozilla/5.0" -s "http://www.geody.com/geoip.php?ip=$1" | grep "^IP.*$1" | html2text; }
    sputnick · 2009-11-06 00:32:27 1
  • Halt script progress until a key has been pressed. Source: http://bash-hackers.org/wiki/doku.php/mirroring/bashfaq/065


    24
    read -sn 1 -p "Press any key to continue..."
    kalaxy · 2009-11-05 21:53:23 0

  • 8
    umount -a -t nfs
    sdadh01 · 2009-11-05 20:57:32 1
  • Simple MAC adrress, thanks to ifconfig.


    0
    ifconfig | awk '/HW/ {print $5}'
    Cont3mpo · 2009-11-05 18:00:50 1

  • -2
    mount | awk '/:/ { print $3 } ' | xargs sudo umount
    uid0 · 2009-11-05 17:19:11 0
  • ...or for a particular interface...


    0
    ip link show eth0 | grep "link/ether" | awk '{print $2}'
    maxmanders · 2009-11-05 17:06:15 0
  • Of course, you can adjust "Maildir" to your config... Show Sample Output


    1
    find ~/Maildir/ -mindepth 1 -type d | egrep -v '/cur$|/tmp$|/new$' | xargs
    ook · 2009-11-05 14:11:29 0
  • Alternative command to retrieve the CPU model name and strip off the "model name : " labels. Show Sample Output


    0
    sed -n 's/^model name[ \t]*: *//p' /proc/cpuinfo
    jgc · 2009-11-05 10:59:31 1
  • require the tex4ht package . You can open the file with openoffice , I use it much for correct my spelling and grammar . Show Sample Output


    2
    htlatex MyFile.tex "xhtml,ooffice" "ooffice/! -cmozhtf" "-coo -cvalidate"
    eastwind · 2009-11-05 10:12:28 1
  • Extracts the model name of the CPU and displays it on screen. Show Sample Output


    3
    grep "model name" /proc/cpuinfo
    getkaizer · 2009-11-05 05:23:30 0
  • ‹ First  < 383 384 385 386 387 >  Last ›

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



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: