Disclaimer: Yes, finding files in a script with ls
is bad, but find
can't sort by modification date.
Using ls
and xargs
with echo
everything is fine:
$ ls -t1 ssl-access*.gz | xargs -n 1 echo
ssl-access.log.2.gz
ssl-access.log.3.gz
ssl-access.log.4.gz
[...]
Changing echo
to zcat
:
$ ls -t1 ssl-access*.gz | xargs -n 1 zcat
gzip: ssl-access.log.2.gz.gz: No such file or directory
gzip: ssl-access.log.3.gz.gz: No such file or directory
gzip: ssl-access.log.4.gz.gz: No such file or directory
[...]
Duplicate file suffixes?! What is going on here?
UPDATE:
OS is Debian 5.
zcat
is a shell script at /bin/zcat
:
#!/bin/sh
PATH=${GZIP_BINDIR-'/bin'}:$PATH
exec gzip -cd "$@"
zcat
executable (probably a shell script) and see if it is auto-appending a.gz
extension.-printf %t
(gnu-only) or-exec stat -c '%X' {}\;
then pipe it tosort
.zcat
a file that is not compressed?gzip: test.txt: not in gzip format
with return code 1.xargs
is running the command for a batch of files at once, and you're not using this capability, so don't even consider using it. About the strange behavior you observe: what doestype zcat
show? What is the full output fromls -t1 ssl-access*.gz
?