Vicheanak
Vicheanak

Reputation: 6684

how to print the exact word from a file by using grep?

I have this file call helloworld.txt:

starthelloworld_some_text.jpgend
starthelloworld_different_text.jpgend
starthelloworld_another_different_one.jpgend

and I would like Grep to display only like this:

helloworld_some_text.jpg
helloworld_different_text.jpg
helloworld_another_different_text.jpg

I a newbie and really need help from you guys. Please show me some ways, I really appreciate for your time. Thanks a lot.

Upvotes: 2

Views: 1453

Answers (1)

Lars Kotthoff
Lars Kotthoff

Reputation: 109232

grep -o "hello.*\.jpg" helloworld.txt

Upvotes: 4

Related Questions