### Commands using eval (56) the last day the last week the last month all time sorted by date votes

• If \$INBACK is set, command will launch in foreground and inverse. Very useful in script ! We could apply the inverse comportement like that : eval command \${INBACK:+&}

-1
eval <command> \${INBACK:-&}
· 2012-04-05 03:50:57
• iterating range of numer with for loop in shell or bash Show Sample Output

-1
rangeBegin=10; rangeEnd=20; for numbers in \$(eval echo "{\$rangeBegin..\$rangeEnd}"); do echo \$numbers;done
· 2019-07-26 09:19:44
• If you put this in your .bashrc, you might also want to add this to make it use the colors by default: `alias ls="ls --color=auto"`

-2
eval "`dircolors -b`"
· 2009-03-27 05:37:04
• It is not easy to make perl give a segfault, but this does it. This is a known issue but apparently not easy to fix. This is completely useless except for showing people that perl is not bullet-proof. Show Sample Output

-2
perl -e '\$x = []; push @\$x, eval { \$x = 1; return \$x = 1; }'
· 2009-10-07 22:42:18
• 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

-4
marbles () { c=''; for i in \$(seq \$1); do c+='{b,r}'; done; x=\$(eval echo \$c); p=''; for i in \$(seq \$2); do p+='b*r'; done; y=\$(grep -wo "\${p}b*" <<< \$x); wc -l <<< "\$y"; grep -vc 'rr' <<< "\$y"; }
· 2010-08-27 23:04:33

• -7
mkdir() { /bin/mkdir \$@ && eval cd "\\$\$#"; }
· 2009-03-30 17:24:21
•  < 1 2 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.

### Check These Out

see who's using DOM storage a/k/a Web Storage, super cookies
Someone over at Mozilla dot Org probably said, "I know, let's create a super-duper universal replacement for browser cookies that are persistent and even more creepy and then NOT give our browser users the tools they need to monitor, read, block or selectively remove them!" . This will let you see all the DOM object users in all your firefox profiles. Feel free to toss a `| sort -u` on the end to remove dupes. . I highly recommend you treat these as "session cookies" by scripting something that deletes this sqlite database during each firefox start-up. . note: does not do anything for so-called "flash cookies"

Make a playlistfile for mpg321 or other CLI player
A short variant if you have only one directory whit only audio files in it.

How to extract 5000 records from each table in MySQL
How to extract data from one table: mysqldump --opt --where="true LIMIT 5000" dbinproduzione tabella > miodbditest_tabella.sql

Run a command multiple times with different subcommands
it's nice to be able to use the command `ls program.{h,c,cpp}`. This expands to `ls program.h program.c program.cpp`. Note: This is a text expansion, not a shell wildcard type expansion that looks at matching file names to calculate the expansion. More details at http://www.linuxjournal.com/content/bash-brace-expansion I often run multiple commands (like apt-get) one after the other with different subcommands. Just for fun this wraps the whole thing into a single line that uses brace expansion.

Windows telnet
Check if TCP port is reacheable

Find out how old a web page is
I used to use the Firefox "View page info" feature a lot to determine how stale the web page I was looking at was. Now that I use mostly Chrome I miss that feature, so here is a command line alternative using wget. The -S says to display the server response, the --spider says to not download any files/pages, just fetch the header. The output goes to stderr, so to grep it you use 2>&1 to combine the stderr stream with stdout, the pipe that to grep for Last-Modified. You can use curl instead if you have it installed, like this: \$ curl --head -s http://osswin.sourceforge.net | grep Mod

Create a file and manipulate the date

Move all files between to date
In a folder with many files and folders, you want to move all files where the date is >= the file olderFilesNameToMove and

List all information about all files (in current dir)
This is a funny usage of the traditional command ls. It could be basically simplified as: \$ ls -a -l Duplicating arguments is permitted: \$ ls -a -l -l And this markup could be shortened as: \$ ls -al Extra note: To view filesizes like a pro, pray for your God: \$ ls -allah