You could have that little benchmark run on all cores in parallel, as a multi-core benchmark or stress test First find the number of cores, then have parallel iterate over that in, well, parallel Show Sample Output
Usefull if you want to check if something is applying a dictonary of brute force.
Great idea camocrazed. Another twist would be to display a different man page based on the day of the year. The following will continuously cycle through all man pages:
man $(ls /bin | sed -n $(($(date +%j) % $(ls /bin | wc -l)))p)
A simple command to find the total number of subdirectories in current directory starting with specific name. Show Sample Output
Not perfect but working (at least on the project i wrote it ;) ) Specify what you want search in var search, then it grep the folder and show one result at a time. Press enter and then it will show the next result. It can work bad on result in the firsts lines, and it can be improved to allow to come back. But in my case (a large project, i was checking if a value wasn't used withouth is corresponding const and the value is "1000" so there was a lot of result ...) it was perfect ;)
This counts all established sessions on port 80. You can change :80 to any port number you want to check. Show Sample Output
Broken in two parts, first get the number of cores with cat /proc/cpuinfo |grep proc|wc -l and create a integer sequence with that number (xargs seq), then have GNU parallel loop that many times over the given command. Cheers! Show Sample Output
Download a bunch of random animated gifs from http://gifbin.com/
The same thing using only Bash built-in's. For readability I've kept the variables out, but it could me made extremely more compact (and totally unreadable!) by stuffing everything inside the single echo command.
it recursively searches your project's directories and sum the lines of every source [.c or .h]. Then it gives you the total.
ls -1 shows one file per line (update: -1 was not really needed) wc -l counts the lines received from the previous command Show Sample Output
prints a random line
Of course, the httpd can be replaced with any other process name Show Sample Output
Suppose you have 11 marbles, 4 of which are red, the rest being blue. The marbles are indistinguishable, apart from colour. How many different ways are there to arrange the marbles in a line? And how many ways are there to arrange them so that no two red marbles are adjacent? There are simple mathematical solutions to these questions, but it's also possible to generate and count all possibilities directly on the command line, using little more than brace expansion, grep and wc! The answer to the question posed above is that there are 330 ways of arranging the marbles in a line, 70 of which have no two red marbles adjacent. See the sample output. To follow the call to marbles 11 4: after c=''; for i in $(seq $1); do c+='{b,r}'; done;, $c equals {b,r}{b,r}{b,r}{b,r}{b,r}{b,r}{b,r}{b,r}{b,r}{b,r}{b,r} After x=$(eval echo $c), and brace expansion, $x equals bbbbbbbbbbb bbbbbbbbbbr ... rrrrrrrrrrb rrrrrrrrrrr, which is all 2^11 = 2048 strings of 11 b's and r's. After p=''; for i in $(seq $2); do p+='b*r'; done;, $p equals b*rb*rb*rb*r Next, after y=$(grep -wo "${p}b*" Finally, grep -vc 'rr' Show Sample Output
Count your source and header file's line numbers For example for java change the command like this find . -name '*.java' -exec cat {} \;|wc -l Show Sample Output
Thanks for the comments Show Sample Output
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.
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
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: