Re: do it all with grep and ls or is there another option
- From: mmccaws2 <mmccaws@xxxxxxxxxxx>
- Date: Tue, 25 Mar 2008 18:12:46 -0700 (PDT)
On Mar 25, 5:46 pm, Janis Papanagnou <Janis_Papanag...@xxxxxxxxxxx>
wrote:
mmccaws2 wrote:
On Mar 25, 5:22 pm, "Chris F.A. Johnson" <cfajohn...@xxxxxxxxx> wrote:
On 2008-03-26, mmccaws2 wrote:
Supposed a simple request
I'd like to search through a directory for all files having Feb in
them that begin with 'q1' then list those files out into a file with
most recent change last. and I need to know how many files.
I get so far
grep Feb q1* | cat -n
but this doesn't give me the most recent last.
ls -ltr q1* | cat -n
give most recent last and counts but it doesn't eliminate q1*s that
don't have 'Feb'
ls -ltr q1*Feb* | cat -n
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
Woops
thanks for your effort, but shame on me for not clarifying that the
Feb is not part of the filename. Feb should be found in a line within
each file name that begins with q1. In fact it'll probably be a date
like Feb 03, 2008, so I'll be looking for a string.
awk '/Feb/{print FILENAME; exit}' $( ls -tr q1* )
(untested)
Janis
Mike
I'm not fluent with awk. I tried it with -ltr and -tr. The -tr gave
a file name but it wasn't the most recent. I got an error with -ltr.
I also was looking for a file count.
Thanks
Mike
.
- Follow-Ups:
- Re: do it all with grep and ls or is there another option
- From: Janis Papanagnou
- Re: do it all with grep and ls or is there another option
- References:
- do it all with grep and ls or is there another option
- From: mmccaws2
- Re: do it all with grep and ls or is there another option
- From: Chris F.A. Johnson
- Re: do it all with grep and ls or is there another option
- From: mmccaws2
- Re: do it all with grep and ls or is there another option
- From: Janis Papanagnou
- do it all with grep and ls or is there another option
- Prev by Date: Re: do it all with grep and ls or is there another option
- Next by Date: Re: do it all with grep and ls or is there another option
- Previous by thread: Re: do it all with grep and ls or is there another option
- Next by thread: Re: do it all with grep and ls or is there another option
- Index(es):
Relevant Pages
|