in reply to Re: one liner error
in thread one liner error
Just to expand for *NIX shells, you need to avoid whitespace and other characters the shell is going to interpret specially: e.g. parens, curlies, braces, splats, dolar signs, ampersands, semicolons, and backslashes (and that's in no ways an exhaustive list). Usually you can backslash them to escape them, but you're going to wind up with leaning toothpick syndrome. It'll be much simpler (to say nothing of fewer characters) if you just break down and (single) quote things and be done with it.
$ uptime | perl -nE m\{\(load\ averages:.\*\)\}\&\&say\$1 load averages: 1.12 1.02 0.95 $ uptime | perl -nE 'm{(load averages:.*)}&&say$1' load averages: 0.84 0.96 0.93
(Insert Jurasic Park quote about could versus should)
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: one liner error
by AnomalousMonk (Archbishop) on May 27, 2020 at 15:22 UTC | |
by Fletch (Bishop) on May 27, 2020 at 15:55 UTC | |
by Anonymous Monk on May 27, 2020 at 17:49 UTC | |
|
Re^3: one liner error
by perlfan (Parson) on May 28, 2020 at 07:05 UTC |