Hi ,
I have few lines like
A20120101.ANU.ZIP
A20120401.ABC.ZIP
A20120105.KJK.ZIP
A20120809.JUG.ZIP
A20120101.MAT.ZIP
B20120301.ANU.XIP
I want to filter by
- Files starting with A and Ending With Z ( ^A.*.ZIP$)
- And either ANU, or KJK or MAT in the file name.
Hope my requirement is clear. Please help.
ls | egrep '^A.*(ANU|KJK|MAT)\.ZIP$'
1 Like
cabrao
3
$ awk '/^A.*.ZIP$/&&(/ANU/||/KJK/||/MAT/)' file
A20120101.ANU.ZIP
A20120105.KJK.ZIP
A20120101.MAT.ZIP
ls A*ANU.ZIP A*KJK.ZIP A*MAT.ZIP
ksh93 or bash with extended globbing turned on:
ls A*@(ANU|MAT|KJK).ZIP
@Scrutinizer: required was A
not [A-Z]
But your 2nd example is great.
1 Like
OK, thanks. I changed my post...
thank you all for helping me out.