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 echossl-access.log.2.gzssl-access.log.3.gzssl-access.log.4.gz[...]Changing echo to zcat:$ ls -t1 ssl-access*.gz | xargs -n 1 zcatgzip: ssl-access.log.2.gz.gz: No such file or directorygzip: ssl-access.log.3.gz.gz: No such file or directorygzip: 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/shPATH=${GZIP_BINDIR-'/bin'}:$PATHexec gzip -cd $@
Combination of ls, xargs and zcat leads to duplicate file name suffixes?
shell;debian;xargs;cat;gzip
I found this problem on my system caused by color ls. In my .bash_profile, I had this:alias ls=ls --colorI found the result by sending it to stat, which printed something handy:$ ls local4.notice-201207* | xargs -n1 -P4 -I{} stat {}stat: cannot stat `\033[0mlocal4.notice-20120711.gz\033[0m': No such file or directoryLook at those null color codes! It was confusing zcat, which attempted to add a .gz suffix to find a file. The problem was easily solved by changing the ls to color=auto, which disables color output when STDOUT is glued to another process instead of a terminalalias ls=ls --color=autoGood luck!