bash perl "and" operator
with a output:
apple text1
peach text2
banana text3
melon text4For delete rows that begin with "apple" or "banana" i put:
perl -pe 's/^apple.*\n|^banana.*\n//g'And output is correct:
peach text2
melon text4But I want delete also an eventual "papaya" or "mango" for example. For achieve this I apply the De Morgan law:
perl -pe 's/^(?!peach).*\n&^(?!melon).*\n//g'But nothing is deleted because while "|" stands for "or", "&" does not work.
What symbol stands for "and" in bash perl command?
1 Answer
You can concatenate the two matching expressions like this:
perl -pe 's/^(?!peach)(?!melon).*\n//g'or you can use the "or" operator like this:
perl -pe 's/^(?!(peach|melon)).*\n//g' 1