Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.


HPR4417: Newest matching file

Hosted by Dave Morriss on 2025-07-08 01:00:00
Download or Listen

HPR Comments


Archer72 says: It's in my memory

RE: hpr4417::2025-07-08 Newest matching file by Dave Morriss
00:22:02 Listen in ogg, opus, or mp3 format.
Dave,

Thanks for the show. This is one that I will have to refer to at a later date. For now, I'm putting in my memory to refer back.

Archer72

ToeJet says: Alternate method

RE: hpr4417::2025-07-08 Newest matching file by Dave Morriss
00:22:02 Listen in ogg, opus, or mp3 format.
I use a similar pattern to find newest and oldest
PATTERN is any valid filename pattern and path if needed
PATTERN=*.txt #Text file in current direcory
PATTERN=/dir1/*.sh #sh file in /dir1
PATTERN=/dir2/[a-j]* #file beginning with a-j in /dir2

#Find Newest
NewFile=$(dir -1tQ ${PATTERN} | head -n 1)
NewFile=${NewFile//\"/} #Remove " in Name

#Find Oldest
OldFile=$(dir -1rtQ ${PATTERN} | head -n 1)
OldFile=${OldFile//\"/} #Remove " in Name

Mastodon Comments



More Information...


Copyright Information

Unless otherwise stated, our shows are released under a Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.

The HPR Website Design is released to the Public Domain.