RHEL 8.
$ alias suip
alias suip='sudo -iu postgres'
If I specify the complete filename, the
ls
command works as expected:
suip ls ~postgres/logs/pgbackrest_2025-04-30_01:00:01_incr.log
/var/lib/pgsql/logs/pgbackrest_2025-04-30_01:00:01_incr.log
Not so much, though, when I use a wildcard:
$ suip ls ~postgres/logs/pgbackrest_2025-04-30*log
ls: cannot access '/var/lib/pgsql/logs/pgbackrest_2025-04-30*log': No such file or directory
The ultimate goal is to find the newest file matching pgbackrest_*log
. Using find(1)
does the job, but I'm wondering why ls(1)
*does not* expand the wildcard.
$ suip find ~postgres/logs -name 'pgbackrest_*log' | sort | tail -n1
/var/lib/pgsql/logs/pgbackrest_2025-05-01_01:00:01_incr.log
Asked by RonJohn
(1421 rep)
May 1, 2025, 02:31 PM