interdimensionalmeme@lemmy.ml to Linux@lemmy.ml · 17 hours agozcat shouldn't error out if you try to zcat an uncompressed file, it should just output the damned file !message-squaremessage-square15fedilinkarrow-up165arrow-down16file-text
arrow-up159arrow-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 · 17 hours agomessage-square15fedilinkfile-text
minus-squareMonkderVierte@lemmy.mllinkfedilinkarrow-up9·edit-22 hours agoBtw, don’t parse ls. Use find |while read -r instead. find -maxdepth 1 -name "term" -print |while read -r file do zcat "$file" 2>/dev/null || cat "$file" done
minus-squareallywilson@lemmy.mllinkfedilinkarrow-up4·5 hours 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-squareMonkderVierte@lemmy.mllinkfedilinkarrow-up1·2 hours agoYeah, i was tired and had $file there first, then saw that you wanted to cat all in directory. Still tired, but i think this works now.
Btw, don’t parse ls. Use
find |while read -r
instead.find -maxdepth 1 -name "term" -print |while read -r file do zcat "$file" 2>/dev/null || cat "$file" done
Won’t this cause cat to iterate through all files in the cwd once zcat encounters an issue, instead of just the specific file?
Yeah, i was tired and had $file there first, then saw that you wanted to cat all in directory. Still tired, but i think this works now.