Lemmy for LUS
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
chraebsli to Programmer Humor@programming.dev • 1 year ago

Touch a file in Linux

programming.dev

message-square
32
fedilink
18

Touch a file in Linux

programming.dev

chraebsli to Programmer Humor@programming.dev • 1 year ago
message-square
32
fedilink
alert-triangle
You must log in or register to comment.
  • Björn Tantau
    link
    fedilink
    4•1 year ago

    Does anyone actually use touch for its intended purpose? Must be up there with cat.

    • @BestBouclettes@jlai.lu
      link
      fedilink
      2•
      edit-2
      1 year ago

      The intended use of touch is to update the timestamp right?

      • Björn Tantau
        link
        fedilink
        2•1 year ago

        Yeah. It could just as well have issued a file not found error when you try to touch a nonexistent file. And we would be none the wiser about what we’re missing in the world.

        • @4am@lemm.ee
          link
          fedilink
          1•1 year ago

          “Do one thing and do it very well” is the UNIX philosophy after all; if you’re 99% likely to just create that missing file after you get a file not found error, why should touch waste your time?

          • Trailblazing Braille Taser
            link
            fedilink
            2•1 year ago

            Because now touch does two things.

            Without touch, we could “just” use the shell to create files.

            : > foo.txt
            
            • @deegeese@sopuli.xyz
              link
              fedilink
              1•1 year ago

              Touch does one thing from a “contract” perspective:

              Ensure the timestamp of is

              • @dan@upvote.au
                link
                fedilink
                1•1 year ago

                Systemd also does one thing from a contract perspective: run your system

    • funkajunk
      link
      fedilink
      English
      1•1 year ago

      TIL it’s actually for changing timestamps.

      https://www.man7.org/linux/man-pages/man1/touch.1.html

      • This is fine🔥🐶☕🔥
        link
        fedilink
        2•1 year ago

        Wtf. All these years I thought ‘touch’ was reference to Michelangelo’s Creation of Adam.

        • funkajunk
          link
          fedilink
          English
          2•1 year ago

          That’s beautiful, bro 🥲

    • @tubaruco@lemm.ee
      link
      fedilink
      0•1 year ago

      what is cat’s use if not seeing whats inside a file?

      • @ulterno@lemmy.kde.social
        link
        fedilink
        English
        1•1 year ago

        It is to use along with split. e.g.

        1. You take a single large file, say 16GB
        2. Use split to break it into multiple files of 4GB
        3. Now you can transfer it to a FAT32 Removable Flash Drive and transfer it to whatever other computer that doesn’t have Ethernet.
        4. Here, you can use cat to combine all files into the original file. (preferably accompanied by a checksum)
        • @Tangent5280@lemmy.world
          link
          fedilink
          0•1 year ago

          Doesnt computers do this automatically if you try to copy over a file larger than its per file size limit?

          • @Octopus1348@lemy.lol
            link
            fedilink
            1•1 year ago

            No. It just gives an error that it’s too big.

      • @Navigate@lemmings.world
        link
        fedilink
        0•1 year ago

        It is short for concatenate, which is to join things together. You can give it multiple inputs and it will output each one directly following the previous. It so happens to also work with just one input.

        • @kautau@lemmy.world
          link
          fedilink
          0•1 year ago

          That’s why we have bat now

          https://github.com/sharkdp/bat

          • Trailblazing Braille Taser
            link
            fedilink
            1•1 year ago

            To bonbatenate files?

  • @dubyakay@lemmy.ca
    link
    fedilink
    2•1 year ago

    These are some weird looking dolph— oh

  • @xmunk@sh.itjust.works
    link
    fedilink
    1•1 year ago

    Remember to confirm consent before touching.

    • @IsoSpandy@lemm.ee
      link
      fedilink
      2•1 year ago

      You can only touch in places where you have permission to touch.

      • @lseif@sopuli.xyz
        link
        fedilink
        0•1 year ago

        sudo touch woman

        • lad
          link
          fedilink
          1•1 year ago

          Iseif is not in the sudoers file. This incident will be reported.

          • @lseif@sopuli.xyz
            link
            fedilink
            0•1 year ago

            to whom, perchance?

            • @gaael@lemmy.world
              link
              fedilink
              2•1 year ago

  • @Zozano@lemy.lol
    link
    fedilink
    1•1 year ago

    images-2

    Same energy as Joan Cornella’s comics

  • @null@slrpnk.net
    link
    fedilink
    1•1 year ago

    Is there a command that’s actually just for creating a new file?

    • @tranzystorek_io@beehaw.org
      link
      fedilink
      English
      1•1 year ago

      most shells will accept outputting from a silent command to a file, e.g. :> foo.txt (where : is the posix synonym to the true command)

    • @dan@upvote.au
      link
      fedilink
      0•1 year ago

      How often do you actually need a blank file though? Usually you’d be writing something in the file.

      • @null@slrpnk.net
        link
        fedilink
        0•1 year ago

        I’m betting that’s why none ever materialized. Most tools that can manipulate a file, can also create that file first, so there’s just never been a usecase.

        Right-clicking the desktop to create a new txt file in Windows feels so natural, but I can’t really think of any time you’d want to create a new file and do nothing with it in a CLI.

        • @schnurrito@discuss.tchncs.de
          link
          fedilink
          1•1 year ago

          You might if some other program checks whether that file exists and behaves differently depending on that.

          • @null@slrpnk.net
            link
            fedilink
            0•1 year ago

            But even still, what’s a realistic usecase that would that involve needing a blank, unmodified file in that instance?

            • @indepndnt@lemmy.world
              link
              fedilink
              1•1 year ago

              One use case is if you’re running a web server that is configured to return a “maintenance” page instead of the live site if a particular file exists. Which is actually pretty cool because then you don’t have to update the config when you need to do something or let your users get a bunch of 502 errors, you just touch maintenance and you’re good.

Programmer Humor@programming.dev

!programmer_humor@programming.dev
Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmer_humor@programming.dev

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
  • 46 users / day
  • 439 users / week
  • 1.24K users / month
  • 3.8K users / 6 months
  • 3 subscribers
  • 1.14K Posts
  • 31.9K Comments
  • Modlog
  • mods:
  • Feyter
  • adr1an
  • @BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne
  • BE: 0.18.5
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org