• 48954246@lemmy.world
      link
      fedilink
      English
      arrow-up
      21
      ·
      edit-2
      8 months ago

      Feels dangerous to run. What happens if the file already exists and has something important in it?

      touch -a is probably better

      • gaterush@lemmy.world
        link
        fedilink
        arrow-up
        9
        ·
        8 months ago

        The other command could just be printf '' >> file to not overwrite it. Or even simpler >>file and then interrupt

        • owsei
          link
          fedilink
          arrow-up
          10
          ·
          8 months ago

          or :>>file then you don’t need to interrupt

          • 4am@lemm.ee
            link
            fedilink
            arrow-up
            6
            ·
            8 months ago

            .“:>>” is “append null” right? Do you get a file with a single ASCII NUL or is it truly empty?

            • owsei
              link
              fedilink
              arrow-up
              3
              ·
              8 months ago

              Yeah!

              it’s basically a noop, I use it as a placeholder when I’m writing a script, since bash doesn’t accept code blocks with no commands