Answer the question
In order to leave comments, you need to log in
How to remove a line from a csv file in which the email is not found?
That is, suppose there is a file containing:
[email protected] 2918241 Ivan
[email protected] 2151221w Kolya
dasdasd sadasdasda asdasdasd
[email protected] dasdasdasd
Accordingly, the third line should be deleted from here, since there is no email in it.
Tried
sed '/[A-Za-z0-9._%+-][email protected][A-Za-z0-9.-]+\.[A-Za-z]{2,6}/!d' filename.csv
failed
Answer the question
In order to leave comments, you need to log in
You can use the SED option -i, which means to make changes to the same file.
You need to use the SED -r option to enable regular expression support.
$ sed -r '/[A-Za-z0-9._%+-][email protected][A-Za-z0-9.-]+\.[A-Za-z]{2,6}/!d' test.txt
[email protected] 2918241 Ivan
[email protected] 2151221w Kolya
[email protected] dasdasdasd
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question