[Eug-lug] help with directory listing
Ben Barrett
stircrazyben at gmail.com
Tue Mar 4 18:34:21 PST 2008
I'd also like to point out the "-1" option for "ls", my most common usage is:
ls -ltr
to show most recent files at the bottom of the listing (oldest first),
long-style listing...
but if I do need to do something with just the filename(s), I'd use
something like this instead:
ls -1tr|tail -n 1
As for nifty usages, you can also have fun with back-ticks, like this:
for i in `ls -1`; do echo filename is $i; done
but of course substituting various options in on ls, can include a
grep inside the backticks, and of course do more useful things than
echo....
ciao,
Ben
On Tue, Mar 4, 2008 at 5:50 PM, Fred James <fredjame at fredjame.cnc.net> wrote:
> Rob Hudson wrote:
>
> >Of course... how could I forget head and tail?!
> >
> >Thanks.
> >
> >On 3/4/08, Hal Pomeranz <hal at deer-run.com> wrote:
> >
> >
> >>ls -t | head -1
> >>
> >>
> Rob Hudson
> Will that do it for you, or do you need something to exclude/include any
> particular type(s) of file(s)?
> Regards
> Fred James
>
>
>
> _______________________________________________
> EUGLUG mailing list
> euglug at euglug.org
> http://www.euglug.org/mailman/listinfo/euglug
>
More information about the EUGLUG
mailing list