kikee1222
kikee1222

Reputation: 2026

Linux command to find directories where numerical directory

I have a directory structure like /store/hour/....

so example: london/04/...

I want to do a day to date report, so say:

show me all directories where the hour is <10 for example

How would I do this in a single command?

Thanks

Upvotes: 0

Views: 73

Answers (1)

swingbit
swingbit

Reputation: 2745

Supposing a /store/hour structure with 2-digit hours, a simple way can be to filter them with egrep:

Hour < 10:

ls -1d /* | egrep '^\/\w+\/0[0-9]$'

Hour < 15:

ls -1d /* | egrep '^\/\w+\/(0[0-9])|(1[0-4])$'

Upvotes: 1

Related Questions