Commands by taliver (5)


  • 2
    leapyear() { [ $(date -d "Dec 31, $1" +%j) == 366 ] && echo leap || echo not leap; }
    taliver · 2010-03-30 20:13:56 36
  • Slightly simpler version of previous sed command that does the same thing. In this case, the output will stop at the command, and the entire command will be terminated as well, instead of proceeding through the whole file.


    1
    command | sed '/regex/q'
    taliver · 2009-12-29 14:52:41 3
  • Uses the dumb terminal option in gnuplot to plot a graph of frequencies. In this case, we are looking at a frequency analysis of words in all of the .c files. Show Sample Output


    5
    cat *.c | { printf "se te du\nplot '-' t '' w dots\n"; tr '[[:upper:]]' '[[:lower:]]' | tr -s [[:punct:][:space:]] '\n' | sort | uniq -c | sort -nr | head -n 100 | awk '{print $1}END{print "e"}'; } | gnuplot
    taliver · 2009-11-20 14:53:26 7
  • This is a quick hack to make a gcc caller. Since it runs with gcc instead of tcc, it's a bit more trustworthy as far as the final answers of things go. Show Sample Output


    -3
    alias cstdin='echo "Ctrl-D when done." && gcc -Wall -o ~/.stdin.exe ~/.stdin.c && ~/.stdin.exe'
    taliver · 2009-11-19 16:38:51 4
  • This uses urandom to produce a random password. The random values are uuencoded to ensure only printable characters. This only works for a number of characters between 1 and 60. Show Sample Output


    -3
    mkpasswd() { head -c $(($1)) /dev/urandom | uuencode - | sed -n 's/.//;2s/\(.\{'$1'\}\).*/\1/p' ;}
    taliver · 2009-11-19 14:27:52 5

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

List .log files open by a pid
Uses lsof to display the full path of ".log" files opened by a specified PID.

Lists the supported memory types and how much your board can support.

generate iso

Reset terminal that has been buggered by binary input or similar

Find default gateway

mail with attachment
An easy one but nice to keep in mind.

list block devices
Shows all block devices in a tree with descruptions of what they are.

Getting the last argument from the previous command

Search gpg keys from commandline

Select and Edit a File in the Current Directory
This command displays a simple menu of file names in the current directory. After the user made a choice, the command invokes the default editor to edit that file. * Without the break statement, the select command will loop forever * Setting the PS3 prompt is optional * If the user types an invalid choice (such as the letter q), then the variable $f will become an empty string. * For more information, look up the bash's select command


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: