Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #286723
| From | Andrew Latham <lathama@gmail.com> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: a hopefully simple ls command question? |
| Date | 2026-05-16 21:30 +0200 |
| Message-ID | <MVsRX-5Dqo-3@gated-at.bofh.it> (permalink) |
| References | <MVelX-5t8F-1@gated-at.bofh.it> <MVmCS-5z7Q-9@gated-at.bofh.it> <MVsoV-5CXY-5@gated-at.bofh.it> <MVsRX-5Dqo-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
In case it helps others I often suggest
https://www.oreilly.com/library/view/classic-shell-scripting/0596005954/
to engineers. It should be very cheap on the secondary market.
And for those that wonder, ls does have a hide but no filter.
--hide=PATTERN
do not list implied entries matching shell PATTERN
(overridden by -a or -A)
On Sat, May 16, 2026 at 1:20 PM Greg Wooledge <greg@wooledge.org> wrote:
>
> On Sat, May 16, 2026 at 14:55:54 -0400, Karen Lewellen wrote:
> > So, if I want to find items ending in .txt from a certain date window, what
> > am I missing?
>
> As you're adding complexity, I would move away from the "ls + text editor"
> approach and toward find.
>
> > I understand the start syntax of the following, still unsure if find needs
> > to be run in quotation marks however, so
> > find - name *.txt -print
> > would print the files ending in .txt to the screen.
> > where would the date be added, and where does that land in the syntax?
>
> OK, to answer your questions:
>
> 1) In this command, the * character needs to be quoted. Usually, people
> will quote the entire word *.txt instead of just the *, but there
> are many different valid ways to write it. '*.txt' or "*.txt" are
> the most common.
>
> 2) If you want to add date information to the output, the simplest way
> would be to use the -ls action instead of the -print action.
>
> Now, two minor corrections:
>
> 1) You wrote "- name" but this should be "-name".
>
> 2) find is supposed to be given a starting directory. GNU find lets
> you omit this argument, and assumes "." as the starting directory.
> However, I still prefer using the correct syntax.
>
> Putting it all together: to list all the files ending with .txt including
> modification times, you can use:
>
> find . -name '*.txt' -ls
>
> If you want more control over the output, you can replace -ls with a
> more complex action, such as -printf FORMAT:
>
> find . -name '*.txt' -printf '%t %p\n'
>
> That shows the modification time in a human-readable format, and the
> full relative path, for each file whose name ends with .txt.
>
> If you want to include date restrictions, you can add those as well:
>
> find . -name '*.txt' -mtime +5 -mtime -11 -printf '%t %p\n'
>
> That one would show files whose names end with .txt, and whose
> modification time is more than 5 days ago, and whose modification time
> is less than 11 days ago.
>
> This is just a starting point. find can do a *lot*.
>
--
- Andrew "lathama" Latham -
Back to linux.debian.user | Previous | Next — Previous in thread | Find similar
a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-16 06:00 +0200
Re: a hopefully simple ls command question? David Christensen <dpchrist@holgerdanske.com> - 2026-05-16 06:30 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-16 09:20 +0200
Re: a hopefully simple ls command question? debian-user@howorth.org.uk - 2026-05-16 12:20 +0200
Re: a hopefully simple ls command question? David Christensen <dpchrist@holgerdanske.com> - 2026-05-17 08:00 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-17 23:20 +0200
Re: a hopefully simple ls command question? Teemu Likonen <tlikonen@iki.fi> - 2026-05-16 07:00 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-16 09:20 +0200
Re: a hopefully simple ls command question? Dan Ritter <dsr@randomstring.org> - 2026-05-16 10:20 +0200
Re: a hopefully simple ls command question? Greg Wooledge <greg@wooledge.org> - 2026-05-16 14:50 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-16 22:30 +0200
Re: a hopefully simple ls command question? Greg Wooledge <greg@wooledge.org> - 2026-05-16 22:50 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-16 23:10 +0200
Re: a hopefully simple ls command question? debian-user@howorth.org.uk - 2026-05-17 18:40 +0200
Re: a hopefully simple ls command question? Dan Ritter <dsr@randomstring.org> - 2026-05-17 01:00 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-17 02:30 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-17 07:30 +0200
Re: a hopefully simple ls command question? John Hasler <john@sugarbit.com> - 2026-05-17 15:20 +0200
Re: a hopefully simple ls command question? John Hasler <john@sugarbit.com> - 2026-05-17 22:10 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-18 00:10 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-18 05:50 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-18 07:00 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-18 07:40 +0200
Re: a hopefully simple ls command question? David Wright <deblis@lionunicorn.co.uk> - 2026-05-18 05:30 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-16 22:40 +0200
Re: a hopefully simple ls command question? Chime Hart <chime@hubert-humphrey.com> - 2026-05-16 22:50 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-16 23:10 +0200
Re: a hopefully simple ls command question? CGS <etphonehomefrance@gmail.com> - 2026-05-17 16:40 +0200
Re: a hopefully simple ls command question? Karen Lewellen <klewellen@shellworld.net> - 2026-05-16 21:00 +0200
Re: a hopefully simple ls command question? Karl Vogel <vogelke+debian@pobox.com> - 2026-05-16 21:50 +0200
Re: a hopefully simple ls command question? Greg Wooledge <greg@wooledge.org> - 2026-05-16 21:30 +0200
Re: a hopefully simple ls command question? Andrew Latham <lathama@gmail.com> - 2026-05-16 21:30 +0200
csiph-web