So I'm grepping for the following right now:
ls -la /somedirectory/*.log* | awk '{print $9}'
The problem with this is that I get the following output:
/somedirectory/errors_1_foo.log
/somedirectory/errors_1_foo.log.1
/somedirectory/errors_1_foo.log.2
/somedirectory/errors_1_foo.log.3
/somedirectory/errors_1_foo.log.4
/somedirectory/errors_1_foo.log.5
The problem is that I only need the following logfiles to show up in the search.
/somedirectory/errors_1_foo.log
/somedirectory/errors_1_foo.log.1
How would I modify my command above to only get these files?
Thanks in advance!
Try:-
ls -1 /somedirectory/*.log /somedirectory/*.log.[0-1]
You don't say that you want to do anything else with these files, so there is no context for us to suggest anything else at the moment.
It might seem a flippant answer, but you've not really asked much.
Note that the flag is a numeric one rather than a lower case L.
Robin
1 Like
Thank you. This is exactly what I need. I haven't had much sleep lately, so I hit a simple wall on this one.
Join the club. Which four letter word is it - kids or work?
Robin
Both, and a three-letter word called "car." I had to do maintenance which involved removing the turbo, replacing some studs,and putting it all back.