On Mon, 19 Nov 2007, Ron Jeffries wrote:

> I have no idea what it
> even means. If someone would care to translate it, I'd be interested
> and grateful.
>
>    `#{ruby} -i.bak -pe 'sub(/^[0-9]+$/){$&.to_i * 5}' script_tmp`

Back tick ` means run the following command and return whatever goes to stdout as a string.

#{ruby} means interpolate into the command string the content of the
  local variable ruby. My guess is the path to the ruby interpreter.

-i.bak is a perlism to operator on the argument "script_tmp" backing
  it up to "script_tmp.bak" prior to feeding it into stdin and stdout
  to "script_tmp"

-p is a perlism to iterate through every line of stdin placing each
  line in default variable $_, execute the chunk of script specified by -e and
  then printing the variable $_ to stdout.

-e '' a perlism to execute the enclosed chunk of ruby.

sub(//){} Operating on the default variable $_
           find the first occurrence of the regexp // and replace it with the result of the block {}

/^[0-9]+$/ Match an integer filling the whole line.

{$&.to_i * 5} Convert it to and integer and multiply by 5

This would only be slow is script_tmp is massive. The backtick would
cause lots of swapping if the size of script_tmp was larger than
available free ram.





John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.carter / tait.co.nz
New Zealand