interdimensionalmeme@lemmy.ml to Linux@lemmy.ml · 13 hours agozcat shouldn't error out if you try to zcat an uncompressed file, it should just output the damned file !message-squaremessage-square11fedilinkarrow-up161arrow-down16file-text
arrow-up155arrow-down1message-squarezcat shouldn't error out if you try to zcat an uncompressed file, it should just output the damned file !interdimensionalmeme@lemmy.ml to Linux@lemmy.ml · 13 hours agomessage-square11fedilinkfile-text
minus-squareallywilson@lemmy.mllinkfedilinkarrow-up14·13 hours agoYeah, it’s a pain. Leads to bad one liners: for i in $(ls); do zcat $i || cat $i; done
minus-squareMonkderVierte@lemmy.mllinkfedilinkarrow-up10·edit-25 hours agoThat’s really bad. zcat ./* 2>/dev/null || cat ./* does the same. Btw, don’t parse ls. Use find |while read -r instead.
minus-squareallywilson@lemmy.mllinkfedilinkarrow-up2·1 hour agoWon’t this cause cat to iterate through all files in the cwd once zcat encounters an issue, instead of just the specific file?
minus-squareinterdimensionalmeme@lemmy.mlOPlinkfedilinkarrow-up6arrow-down1·edit-212 hours agoThanks ! But still we shouldn’t have to resort to this ! Also, can’t get the output through pipe for i in $(ls); do zcat $i || cat $i; done | grep mysearchterm this appears to work find . -type f -print0 | xargs -0 -I{} sh -c 'zcat "{}" 2>/dev/null || cat "{}"' | grep "mysearchterm" Still, that was a speed bump that I guess everyone dealing with mass compressed log files has to figure out on the fly because zcat can’t read uncompressed files ! argg !!! for i in $(ls); do zcat $i 2>/dev/null || cat $i; done | grep mysearchterm
Yeah, it’s a pain. Leads to bad one liners:
for i in $(ls); do zcat $i || cat $i; done
That’s really bad.
zcat ./* 2>/dev/null || cat ./*
does the same.Btw, don’t parse ls. Use
find |while read -r
instead.Won’t this cause cat to iterate through all files in the cwd once zcat encounters an issue, instead of just the specific file?
Thanks !
But still we shouldn’t have to resort to this !
Also, can’t get the output through pipefor i in $(ls); do zcat $i || cat $i; done | grep mysearchterm
this appears to workfind . -type f -print0 | xargs -0 -I{} sh -c 'zcat "{}" 2>/dev/null || cat "{}"' | grep "mysearchterm"
Still, that was a speed bump that I guess everyone dealing with mass compressed log files has to figure out on the fly because zcat can’t read uncompressed files ! argg !!!for i in $(ls); do zcat $i 2>/dev/null || cat $i; done | grep mysearchterm