I have this file:
$ cat ciao
ciao
ciao
ciii
ciaooo
ocisdjoo
kdvkks
kdafjdjf
akfk
and
$ sed ciao -n -e "1,3p"
ciao
ciao
ciii
$ sed ciao -n -e "1,3!p"
sed ciao -n -e "1,3ps -aux | grep nano"
sed: -e expression #1, char 5: extra characters after command
$
If I press arrow up to see the previous command:
$ sed ciao -n -e "1,3ps -aux | grep nano"
WHY??
Shouldn't I see:
ciaooo
ocisdjoo
kdvkks
kdafjdjf
akfk
If I use a sed filter, it works!
$ sed -n -f filter.sed
where filter.sed is simply:
1,3!p
sed
, but it has the exact same issue and symptom. The best approach for you would likely be to single quotes in place of double quotes around thesed
editing expression. – Kusalananda Nov 17 '22 at 07:55