On Fri, May 15, 2026 at 23:46:38 -0400, Karen Lewellen wrote:
Hi folks,
Will aim to ask this simply enough.
is there an option for the ls command allowing you to set the date window >> you are searching?
For example, list only the items added on a certain series of days?
Others have recommended find(1) and that's a valid solution. It's very powerful and worth learning. I also have a wiki page for it: <https://mywiki.wooledge.org/UsingFind>
If you really want to do it with ls(1) and not find(1), you'll need to perform a multiple-step, manual process:
ls -lt > /tmp/list
Open /tmp/list in a text editor.
Find the first file you want to keep, and delete every line above it.
Find the last file you want to keep, and delete every line below it.
Save and exit.
At this point, /tmp/list will contain an "ls -l" listing of all the
files you want, sorted by modification time.
If you want anything more complex than that, find(1) is the right tool
for the job.
So, if I want to find items ending in .txt from a certain date window, what am I missing?
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?
On Sat, May 16, 2026 at 14:55:54 -0400, Karen Lewellen wrote:what
So, if I want to find items ending in .txt from a certain date window,
"am I missing?
As you're adding complexity, I would move away from the "ls + text editor
approach and toward find.eds
I understand the start syntax of the following, still unsure if find ne
eto 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, peopl
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*.
On Sat 16 May 2026 at 14:56:30 (-0400), Karen Lewellen wrote:
Hi Greg,
I have no issues using find. I simply have never heard of the option until now, as my Linux access is only via shell services. [...]
where would the date be added, and where does that land in the syntax?
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*.
On Sat 16 May 2026 at 14:56:30 (-0400), Karen Lewellen wrote:
Hi Greg,
I have no issues using find. I simply have never heard of the option until >> now, as my Linux access is only via shell services. [...]
where would the date be added, and where does that land in the syntax?
Greg's "find" examples showed up as I was writing my reply; this just
gives some context.
Here's a list of the HTML files in one of my project directories:
me% cd /home/vogelke/projects/html-dir/
me% ls -l *.htm
-rw-r--r-- 1 vogelke mis 325 Dec 13 05:39 FOOTER.htm
-rw-r--r-- 1 vogelke mis 464 Dec 13 05:39 HEADER.htm
-rw-r--r-- 1 vogelke mis 6218 Jan 31 2025 example.htm
-rw-r--r-- 1 vogelke mis 6708 Dec 13 05:57 index.htm
-rw-r--r-- 1 vogelke mis 587 Dec 13 05:42 tree.htm
-rw-r--r-- 1 vogelke mis 7766 Dec 6 02:40 wanted.htm
If you're on a Linux system like Debian that has the GNU tools installed,
you can make "ls" be more specific about the modified date and time:
me% ls -l '--time-style=+%d-%b-%Y %T' *.htm
-rw-r--r-- 1 vogelke mis 325 13-Dec-2025 05:39:34 FOOTER.htm
-rw-r--r-- 1 vogelke mis 464 13-Dec-2025 05:39:30 HEADER.htm
-rw-r--r-- 1 vogelke mis 6218 31-Jan-2025 20:16:22 example.htm
-rw-r--r-- 1 vogelke mis 6708 13-Dec-2025 05:57:42 index.htm
-rw-r--r-- 1 vogelke mis 587 13-Dec-2025 05:42:47 tree.htm
-rw-r--r-- 1 vogelke mis 7766 06-Dec-2025 02:40:24 wanted.htm
If you want to search for a date or a range of dates, then the other
people in this thread are right -- use "find". Always put the string
you're looking for in quotes, or else your shell might replace (say)
*.txt with only the files named *.txt in your current directory.
"find" accepts the directory you're interested in as the first argument, which in this case is the current directory:
me% find . -name '*.htm' -print
./wanted.htm
./FOOTER.htm
./tree.htm
./index.htm
./example.htm
./HEADER.htm
Notice that (unlike ls output) the files aren't sorted. That's because "find" reads them in the order they were created on disk. You can add additional information by using "-printf":
me% find . -name '*.htm' -printf "%TF %TT %p\n"
2025-11-06 02:40:24 ./wanted.htm
2025-12-13 05:39:34 ./FOOTER.htm
2025-12-13 05:42:47 ./tree.htm
2025-12-13 05:57:42 ./index.htm
2025-01-31 20:16:22 ./example.htm
2025-12-13 05:39:30 ./HEADER.htm
Since the modification dates are printed in ISO format (YYYY-MM-DD),
sensible sorting is much easier:
me% find . -name '*.htm' -printf "%TF %TT %p\n" | sort
2025-01-31 20:16:22 ./example.htm
2025-11-06 02:40:24 ./wanted.htm
2025-12-13 05:39:30 ./HEADER.htm
2025-12-13 05:39:34 ./FOOTER.htm
2025-12-13 05:42:47 ./tree.htm
2025-12-13 05:57:42 ./index.htm
You can certainly use the -mtime option, but "grep" might also do the trick. If you wanted files between January and September of 2025:
me% find . -name '*.htm' -printf "%TF %TT %p\n" | sort | grep 2025-0
2025-01-31 20:16:22 ./example.htm
If you wanted files after September of 2025 (month number starts with 1):
me% find . -name '*.htm' -printf "%TF %TT %p\n" | sort | grep 2025-1
2025-11-06 02:40:24 ./wanted.htm
2025-12-13 05:39:30 ./HEADER.htm
2025-12-13 05:39:34 ./FOOTER.htm
2025-12-13 05:42:47 ./tree.htm
2025-12-13 05:57:42 ./index.htm
You can do all sorts of bizarre things with "find" and "grep".
Hope this helps.
--
Karl Vogel I don't speak for anyone but myself
Comment: But I'm not a tech person!
Reply: I'm not a mechanic, but if the engine suddenly sounds like a live
cat being fed into a garbage disposal, I know enough to pull over.
--Seen on Reddit, 8 May 2026
Also, because I create many text files in a given day, my goal is very tight here, but it seems I cannot provide actual dates, just a number of days window?
There is not a syntax for say the window of 12 may, say 5 days ago until
14 may, which would be 2 days ago?
On Sat, May 16, 2026 at 16:25:41 -0400, Karen Lewellen wrote:
Also, because I create many text files in a given day, my goal is very tight >> here, but it seems I cannot provide actual dates, just a number of days
window?
There is not a syntax for say the window of 12 may, say 5 days ago until >> 14 may, which would be 2 days ago?
There are lots of ways to solve this problem. Here's another approach:
touch -t 202605120000 /tmp/start
touch -t 202605150000 /tmp/end
find . -name '*.txt' -newer /tmp/start ! -newer /tmp/end -print
rm /tmp/start /tmp/end
This creates two temporary files whose timestamps delimit the period
of time we're interested in: from the start of 2026-05-12 to the
start of 2026-05-15. This is a period lasting 72 hours (3 days).
As before, you can replace -print with -ls or -printf if you want a
different output format.
Well, Karen-and-All: I will suggest 2 concepts, but maybe 1 solution. If there
were a particular word or phrase, you could run "grep" but I know little about
syntax? Also might be time consuming-and-maybe tax Shellworld. What I would suggest might still take you alot of time, but at least its menu-driven. Why not type
lynx .
Yes that would be lynx space and a period
Depending on how you have files sorted in L Y N X you can just arrow through them or like any other site, run searches. I find there are times looking over
files-and-directories are much smoother through lynx. Hope that helps alot Chime
My goal is clear text, that my screen reader can manage, when I use its own review mode.
Does that make more sense?
My goals are very tight, as I want to locate a file I saved within this
small window, with screen output that my talking computer manages.
Karen Lewellen wrote:
My goal is clear text, that my screen reader can manage, when I use its own >> review mode.
Does that make more sense?
My goals are very tight, as I want to locate a file I saved within this
small window, with screen output that my talking computer manages.
This makes sense. We are handicapped by not having experience
with your precise tools, so we are trying to explain all the
tools that might do what you require.
I have found in many situations that I want to store files in a
directory tree rather than a single directory:
/home/files/2026/05/12/acorn.txt
/home/files/2026/05/12/mighty-oak.txt
and if I then want to compile a file which is the sum of every
note about project mighty-oak, I use
cat 2026/*/*/mighty-oak.txt >> current-mighty-oak.txt
The >> symbols cause the various files to all be added to the
receiving file, rather than each one replacing it.
I would use a simple shell script to create today's directory if
it does not already exist:
#!/bin/sh
$TODAY=`date +%Y/%m/%d`
mkdir -p /home/files/$TODAY
On the other hand, if you routinely put dates inside your text
files, you could use
grep -rl 20250417 *txt
Will look for the date 20250417 in every file in the current
directory tree with a txt extension, and print their names.
I hope these ideas help.
On Sat 16 May 2026 at 16:25:41 (-0400), Karen Lewellen wrote:il
Hi Greg,
Thanks, I am aiming for solidity here.
I am using a screen reader.
The text editor wording is a bit confusing.
Also, because I create many text files in a given day, my goal is very
tight here, but it seems I cannot provide actual dates, just a number
of days window?
There is not a syntax for say the window of 12 may, say 5 days ago unt=
een14 may, which would be 2 days ago?
if I follow using . provides my home directory, where my files are
stored, is that correct? This is not my desktop, but a service.
I do understand that I should write say "*.txt"
However I need to be sure I have corrected the mistake you noted,
should it be namef with the dash character?
Your extras with print seem profoundly complex.
My goal is clear text, that my screen reader can manage, when I use
its own review mode.
Does that make more sense?
My goals are very tight, as I want to locate a file I saved within
this small window, with screen output that my talking computer
manages.
I use a bash function for this task. I've attached it as some of the
lines are a bit long. I have it in my ~/.bashrc, making it always
available.
You can try it out by saving the attachment, and then typing:
$ bash -c '. ./find-between; find-between today yesterday ./ | less'
which will give you a list of recent files in this directory,
piped into less as there may be many files in the list.
The function is documented, as can be seen by typing:
$ bash -c '. ./find-between; find-between'
Usage: find-between timedate timedate top-of-trees =E2=80=A6
finds files under top-of-trees with modification timestamps betw=
the two timedates given (free format, in any order; hint: '2000-=12-31 11:59'
is a simple format that works). The output is sorted by filename==2E
$
If you add the find-between file to your .bashrc, then you only have
to type the function name:
$ find-between
$ find-between today yesterday ./ | less
Obviously you would replace today and yesterday with real dates/times.
Their format is whatever is acceptable to date --d (see man date).
The order doesn't matter.
All files are listed, but it's a simple matter to grep the outout:
$ find-between today yesterday ./ | grep 'txt$' | less
though you lose the header line as it's unlikely to match:
From 2026-05-15 21:57:42-05:00 to 2026-05-16 21:57:42-05:00
20260516-081119.08 2136 .Xresources
[ =E2=80=A6 lots more filenames =E2=80=A6 ]
[Aside: replace the echo commands if they offend you.
I have msgerr and msgout functions in their place.]
Cheers,
David.
...
This is not my desktop, with my not having permission to add software.
Hi Chime,
Those suggestions are profoundly helpful.
Because I know approximate dates, I am using this as my focus instead of file names. I tend to save things in work code for me, with my doing allot of professional work in those windows.
Its a situation where I will know, as soon as the name shows, that it is
the one I need...but a general search will create far more data then is helpful.
Does that resonate?
I am a bit lost.
where are the temp files?
honestly, I just want a simple file display showing what might be a
dozen file names in this specific window.
why is this not possible?
Kare
On Sat, 16 May 2026, Greg Wooledge wrote:
On Sat, May 16, 2026 at 16:25:41 -0400, Karen Lewellen wrote:
Also, because I create many text files in a given day, my goal is
very tight here, but it seems I cannot provide actual dates, just
a number of days window?
There is not a syntax for say the window of 12 may, say 5 days
ago until 14 may, which would be 2 days ago?
There are lots of ways to solve this problem. Here's another
approach:
touch -t 202605120000 /tmp/start
touch -t 202605150000 /tmp/end
find . -name '*.txt' -newer /tmp/start ! -newer /tmp/end -print
rm /tmp/start /tmp/end
This creates two temporary files whose timestamps delimit the period
of time we're interested in: from the start of 2026-05-12 to the
start of 2026-05-15. This is a period lasting 72 hours (3 days).
As before, you can replace -print with -ls or -printf if you want a different output format.
On 5/16/26 00:11, Karen Lewellen wrote:
...
Previous posts skipped to expedite screen reader.
Here is a command pipeline using ls(1) and grep(1) that should list the filenames you want to examine:
ls -l -G -R -t --time-style=long-iso . | egrep '2026-05-1[234].*txt$'
"Learning the Unix Operating System" is excellent. It can help you understand the above. I wish I had read it years ago. ebooks offers it via a PDF file, via an EPUB file, and via an online reader that allows you to "Read online in a web browser with nothing to download or install" [1].
David
[1] https://www.ebooks.com/en-us/book/1664451/learning-the-unix-operating-system/jerry-peek/
Copy the script below to your home directory on your shell server.
I call the script "findbetween" but you can rename it if you wish.
Run this command:
chmod a+x findbetween
Run this command:
alias findbetween="$HOME/findbetween"
Typing findbetween should now print a usage message.
Adding the above command to the end of the .bash_profile file in
your home directory should make the change permanent.
-----NEXT LINE IS FIRST LINE OF THE SCRIPT----
#!/bin/bash
# This program is free software. You may treat it as if it were
# in the public domain. You are free to make and distribute copies
# and derivatives. John Hasler 2026-05-17
if [ "$#" -ne 2 ]; then
cat <<EOF
This program lists files in the current directory that are newer or as new as the first date on the command line but no newer than the second one.
The dates must be in ISO standard form (without seconds) and in single quotes.
The exact format is important. Note the leading zeros.
Example:
'2026-05-12 09:41' '2026-05-16 20:52'
EOF
exit 1
fi
startdate=$1
enddate=$2
export startdate
export enddate
ls -tuo --full-time | awk '
{start = ENVIRON["startdate"]}
{end = ENVIRON["enddate"]}
{date = $5 " " substr($6, 1, 5)}
{if (date >= start && date <= end) print date " " $8 }
'
-----PREVIOUS LINE IS THE LAST LINE OF THE SCRIPT----
Note that the last line of the script contains only
a single "'".
--
John Hasler
john@sugarbit.com
Elmwood, WI USA
I use a bash function for this task. I've attached it as some of the
lines are a bit long. I have it in my ~/.bashrc, making it always
available.
[Aside: replace the echo commands if they offend you.
I have msgerr and msgout functions in their place.]
[ "$Timea" = "$Timeb" ] && msgerr "Times are the same (one minute resolution)" && return 1?
On Sun 17 May 2026 at 01:28:44 (-0400), Karen Lewellen wrote:
Hi David,
This is not my desktop, with my not having permission to add software.
I am aware of that. As far as I can ascertain, you buy two services, dreamhost, a web hosting service, and shellworld, which we're involved
with here.
Shellworld says that they supply linux shell accounts, though they
don't appear to say which one, on the sole web page I can find of
theirs. So I think we're all assuming it's bash.
You seemed to understand the concept of a "home directory", though
you thought that . specified it: it doesn't. In bash, ~ stands for
the home directory, and . stands for the current working directory,
the one you're "in".
You've spoken about your shell workspace, something I assume is
part of the shellworld service. Can you explain whether that is
the home directory of your shell account, and if it isn't, then
what it actually is.
As for "added software", it's difficult for me to conceive of a linux
shell account that lacks awk, date, grep, rm, touch, ie the commands
used by different people's suggestions. So no one is asking you to
install software for such a trivial task.
I do thank you, and everyone else, for ideas.
Speaking personally though, one thing I learned from all the options
sort of underscores a long held stance of my own.
If one wanted a hand clapping program in Linux, you would likely end
up with three. one for the right, one for the left, and a third to
make them clap smiles.
Leaving aside the implied and unneeded criticism here, linux has such
an abundance of tools that it's hardly surprising that different users
choose different ones as their goto favourites. Find is an obvious
direct method for solving your problem, but not everybody is familiar
with all its options?hence the workaround of piping a list of all the
files from ls into grep, to filter the ones you want.
At this stage, speaking personally, it might be faster for me to find
the article again creating a new file and name.
It may well be. Remarkably, people on this list tend to assume that
you're sitting at a linux computer with a command line and a screen
reader. And you're not. So it might help to explain exactly what is
available to you in a shellworld shell account. Otherwise we end up
with another thread full of miscommunication, which can end up getting acrimonious, as has sometimes happened here in the past.
My main desktop uses DOS.
Yes, we know?the fantastical magical world in which everything works consistently.
But that doesn't tell us much about your shell account.
For me, I could locate this with a simple single command...and I have
been spoiled by the ease of ls -l when hunting through scores of
things on my Linux shell services.
Of course you could. It takes little more than piping ls -l into
a pretty simple grep. Are you at all familiar with grep?
Cheers,
David.
On Sun 17 May 2026 at 23:45:18 (-0400), Karen Lewellen wrote:
David,
My personal circumstances have nothing to do with the nature of this task.
I have no interest in your /personal/ circumstances.
dreamhost manages the shell accounts of my employer.
Forgive me?I should have said use rather than purchase.
Including the workspaces, more than one of them I use for my jobs.
www.curtainupdistribution.org
www.commongroundmedia.ca
Shellworld hosts my personal website, as well as providing this account.
Well at least I guessed that shellworld is the one involved here.
One rather intense reminder I get from the shellworld side is about
the use of space, files, configurations and so forth.
therefore, as I literally cannot reach my office workspace, or check
my gmail account without the door shellworld provides i. e.openssh
stopped supporting direct dh keys that dreamhost allows years ago, i
personally choose to leave this infrastructure alone.
That's why I included instruction on how to run the attachment
I posted without having to put it into whatever shell configuration
you have. The bash -c command first sources the saved attachment,
and then it runs it with the three arguments, piping the potentially voluminous output into less.
Add that the situation leading to my question is my first in over 25
years, and well.
Kare
Sorry, I don't understand "situation", whether it's to do with your
having to search for a file you created during a certain time
interval, or whether it's to do with your shell account, about which
I know the same as a few days ago, ie precious little.
Cheers,
David.
David,n=20
I have not needed to relocate a lost file name on my shellworld account i=
more than 25 years.=20
Meaning this is the first time ever, and why I reached for a tool I felt=
added nothing whatsoever to the infrastructure here.
The problem has been solved in any case.
Kare
On Sun, 17 May 2026, David Wright wrote:=20
On Sun 17 May 2026 at 23:45:18 (-0400), Karen Lewellen wrote:
David,
My personal circumstances have nothing to do with the nature of this=
task.
I have no interest in your /personal/ circumstances.
=20
dreamhost manages the shell accounts of my employer.
Forgive me=E2=80=94I should have said use rather than purchase.
=20
Including the workspaces, more than one of them I use for my jobs.
www.curtainupdistribution.org
www.commongroundmedia.ca
Shellworld hosts my personal website, as well as providing this accou= nt.
Well at least I guessed that shellworld is the one involved here.
=20
One rather intense reminder I get from the shellworld side is about
the use of space, files, configurations and so forth.
therefore, as I literally cannot reach my office workspace, or check
my gmail account without the door shellworld provides i. e.openssh
stopped supporting direct dh keys that dreamhost allows years ago, i
personally choose to leave this infrastructure alone.
That's why I included instruction on how to run the attachment
I posted without having to put it into whatever shell configuration
you have. The bash -c command first sources the saved attachment,
and then it runs it with the three arguments, piping the potentially
voluminous output into less.
=20
Add that the situation leading to my question is my first in over 25
years, and well.
Kare
Sorry, I don't understand "situation", whether it's to do with your
having to search for a file you created during a certain time
interval, or whether it's to do with your shell account, about which
I know the same as a few days ago, ie precious little.
Cheers,
David.
=20
=20
| Sysop: | Jacob Catayoc |
|---|---|
| Location: | Pasay City, Metro Manila, Philippines |
| Users: | 4 |
| Nodes: | 4 (0 / 4) |
| Uptime: | 495146:44:23 |
| Calls: | 165 |
| Files: | 574 |
| D/L today: |
29 files (9,998K bytes) |
| Messages: | 78,216 |