anandan ramar
anandan ramar

Reputation: 47

grep for particular pattern from a list of files and exclude others

new_aged_01
new_aged_01_b
new_aged_01.bak
new_aged_02
new_aged_02_b
new_aged_02.bak
new_aged_03
new_aged_03_b
new_aged_03.bak

I have a list of files given above, like to use grep to give me output like below,

new_aged_01
new_aged_02
new_aged_03

I tried grep , but it did not work

Upvotes: 2

Views: 403

Answers (1)

A. Gille
A. Gille

Reputation: 1048

Using simple regular expression (regex):

grep -E '^new_aged_\d+$'

See result on regex101.com

Upvotes: 1

Related Questions