### 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

Convert entire audio library in parallel
Uses parallel processing Reiteration of my earlier command https://www.commandlinefu.com/commands/view/15246/convert-entire-music-library Usage lc Old_Directory New_DIrectory Old_Format New_Format lc ~/Music ~/Music_ogg mp3 ogg

Show what PID is listening on port 80 on Linux

RDP through SSH tunnel
This command will: 1. open an SSH tunnel to 2. go to background 3. wait for 10 seconds for the connection 4. during the 10 seconds wait it will localy run 'rdesktop' to connect to the remote host through the created SSH tunnel. Password-less log in can be achieved (when server allows it) by adding '-p ' to the 'rdesktop' command

Find the package that installed a command

Given process ID print its environment variables
Same as previous but compatible with BSD/IPSO

Convert CSV to JSON

For instance: \$ find . -type f -name '*.wav' -print0 |xargs -0 -P 3 -n 1 flac -V8 will encode all .wav files into FLAC in parallel. Explanation of xargs flags: -P [max-procs]: Max number of invocations to run at once. Set to 0 to run all at once [potentially dangerous re: excessive RAM usage]. -n [max-args]: Max number of arguments from the list to send to each invocation. -0: Stdin is a null-terminated list. I use xargs to build parallel-processing frameworks into my scripts like the one here: http://pastebin.com/1GvcifYa

You can view the man pages from section five by passing the section number as an argument to the man command

Perl Command Line Interpreter
Can also just use the debug mode like this.

Alternative for machines without ssh-copy-id