uxez
uxez

Reputation: 43

Finding lines containing '@' sign

Is there possibility to use awk to find email adresses? I got some file with text like

www.examplesite1.com
login=user1
www.gmail.com
[email protected]

to find login lines I'm using

awk '/user=*/' file.txt

Don't know how to find line which contains '@'

Thanks for helping :)

Upvotes: 0

Views: 40

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174844

For finding the lines containing @ symbol.

awk '/@/' file.txt

For finding the lines startswith login and contain @ in it's value.

awk '/^login=.+@.+/' file.txt

And to get the text after =

$ awk '/^login=.+@.+/{sub(/^login=/, ""); print}' file
[email protected]

Upvotes: 2

Related Questions