I have a text file, let say test1.txt
, I need to remove the line containing dog and date with "29-APR-2015"
Using the below command to accomplish it but it is not deleting the lines.
Where as if i mention just with /DOG/d
it is deleting the lines containing DOG
.
command file (sedcommands)
/DOG,29-APR-2015/d
test1.txt
DOG 29-APR-2015
DOG 29-APR-2015
DOG 30-APR-2015
CAT 29-APR-2015
CAT 29-APR-2015
command
sed -f sedcommands test1.txt > test2.txt
sed --posix '/DOG/{/29-APR-2015/d}'
works fine in GNU sed version 4.2.1 (with all GNU extensions disabled). – Peter.O Apr 30 '15 at 04:11}
. At least your command won't work in BSD sed. – cuonglm Apr 30 '15 at 04:28sed
's--posix
is to tell it to be more POSIX conformant. It's not telling it to report an error on any non-POSIX code you throw at it. It would not make GNUsed
more POSIX conformant to report an error when you give it that non-standard{xxx}
code. – Stéphane Chazelas May 04 '15 at 16:25