There I said it !

  • allywilson@lemmy.ml
    link
    fedilink
    arrow-up
    12
    ·
    15 小时前

    Yeah, it’s a pain. Leads to bad one liners:

    for i in $(ls); do zcat $i || cat $i; done

      • allywilson@lemmy.ml
        link
        fedilink
        arrow-up
        4
        ·
        4 小时前

        Won’t this cause cat to iterate through all files in the cwd once zcat encounters an issue, instead of just the specific file?

        • MonkderVierte@lemmy.ml
          link
          fedilink
          arrow-up
          1
          ·
          1 小时前

          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.

    • interdimensionalmeme@lemmy.mlOP
      link
      fedilink
      arrow-up
      3
      arrow-down
      1
      ·
      edit-2
      15 小时前

      Thanks !

      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