F
F
fedot13252015-12-31 08:02:24
linux
fedot1325, 2015-12-31 08:02:24

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

2 answer(s)
S
Saboteur, 2015-12-31
@fedot1325

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

B
bockor, 2015-12-31
@bockor

grep [email protected] > filename1.csv

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question