0

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
Allexj
  • 241
  • 1
  • 9
  • 4
    That csh-style history expansion. Use single quotes instead of double quotes. You may want to disable history expansion if you're not using it. – Stéphane Chazelas Mar 01 '22 at 11:49
  • thanks a lot :) – Allexj Mar 02 '22 at 21:14
  • The question I've marked this as a duplicate of does not deal with `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 the `sed` editing expression. – Kusalananda Nov 17 '22 at 07:55

0 Answers0