• ɐɥO
    link
    fedilink
    84
    edit-2
    1 year ago

    I remember it like this:
    tar -extract ze file
    and
    tar -compress ze file

  • @[email protected]
    link
    fedilink
    English
    531 year ago

    I hope whoever thought -l should mean “check links” instead of list has a special place in Hell set aside for them.

    I have no idea what print a message if not all links are dumped even means.

  • @[email protected]
    link
    fedilink
    291 year ago

    Ah yes, that’s the linux community as I know it. There is one thing someone wants to achieve and dozens of ways to do it. ;)

  • aard
    link
    fedilink
    181 year ago

    You also don’t need the dash for the short options.

    Also, if you’re compressing with bzip2 and have archives bigger than a few megabytes I’ll like you a lot more if you do it with --use-compress-prog=pbzip2

    • @[email protected]OP
      link
      fedilink
      27
      edit-2
      1 year ago

      You also don’t need the dash for the short options.

      True, but I refuse to entertain such a non-standard option format. It’s already enough to tolerate find’s.

      • aard
        link
        fedilink
        161 year ago

        Technically the notation with dashes is the non-standard one - the dash form is a GNU addition. A traditional tar on something like Solaris or HP-UX will throw an error if you try the dash notation.

          • aard
            link
            fedilink
            71 year ago

            Don’t try to take my raw ground pork away from me.

            • Lvxferre
              link
              fedilink
              31 year ago

              my raw ground pork away from me.

              Who are you, the Mett demon?
              Matt Damon made out of mett\

              (It works great with beef, too. Bonus points for the raw yolk over it. If not homemade though there’s literally one bar that I trust with this, salmonella is not fun.)

              • aard
                link
                fedilink
                21 year ago

                Not enough onions. Your average mettigel has better mett/onion ratio.

            • Leo
              link
              fedilink
              English
              11 year ago

              That’s an audible “yuck” from me, man. Well done!

    • @killeronthecorner
      link
      111 year ago

      You also don’t need the dash for the short options.

      You know when you meet someone and you’re just like “oh boy, yeah, they’re evil. No humanity at all”

    • Programmer Belch
      link
      fedilink
      English
      21 year ago

      I think the -j also compresses with bzip2 but I’m not sure if this is defined behavior or just a shortcut

      • @[email protected]
        link
        fedilink
        English
        31 year ago

        There’s nothing technically wrong with using xjf rather than xzf, but it’ll bite you if you ever use a non-linux platform as it’s a GNU extension. I’m not even sure busybox tar supports it.

      • aard
        link
        fedilink
        31 year ago

        Yes, but I’m asking you to use pbzip. bzip at best utilizes one core, both for packing and unpacking. pbzip uses as many cores as IO bandwith allows - with standard SATA SSDs that’s typically around 30.

        pbzip can only utilize multiple cores if the archive was created with it as well.

          • Programmer Belch
            link
            fedilink
            English
            31 year ago

            I’ve searched for it and xz also doesn’t use multithreading by default, you can change the program tar uses to compress by passing the -I option. For xz using all possible CPU threads:

            tar -cv -I 'xz -6 -T0' -f archive.tar.xz [list of directories]

            The number indicates the compression ratio, the higher the number, the more compressed the archive will be but it will cost more in terms of memory and processing time

            • TheSaneWriter
              link
              fedilink
              English
              21 year ago

              Thanks for answering your own question, this is useful information.

  • wvstolzing
    link
    fedilink
    181 year ago

    Those are straightforward; it’s the remaining 900 options that are confusing. I always need to look up --excludes and always get --directory wrong, somehow.

  • @[email protected]
    link
    fedilink
    171 year ago

    Why when explaining, giving examples of shell command are people so often providing shortened arguments. It makes it all seam like some random letters you have to remeber by heart. Instead of -x just write --extract. If in the end they endup using the tool so often they need to write it fast they’ll check the shortcuts.

        • @[email protected]
          link
          fedilink
          51 year ago

          tar -xf is not really special combining short options isn’t uncommon.

          Where tar is nonstandard is that you can leave out the -, tar xf is actually how POSIX specifies it. And we’ve kinda come full circle on that one with many modern utilities using a command syntax, you can read tar xf as “tar extract file” just as you can read git pull as, well, “git pull”.

          If you want to see a standard command with truly non-standard syntax have a look at dd.

      • @[email protected]
        link
        fedilink
        6
        edit-2
        1 year ago

        Many do as it’s considered good practice, but it’s not guaranteed, it just depends on the individual command (program). Usually you can use the --help option to see all the options, so for instance tar --help.

      • @[email protected]
        link
        fedilink
        41 year ago

        Most commands will have expanded arguments started with 2 dashes that usually look like ‘–verbose-name-of-option’, they’re usually listed in the man page/documentation along with the abbreviated letter version

    • @[email protected]
      link
      fedilink
      English
      01 year ago

      They are random letters you have to learn by hard. No one uses the long form. If someone just needs to use it one time they will copy the line from somewhere.

  • @Gecko
    link
    English
    161 year ago

    Or just use long-forms like

    tar --create --file pics.tar ./pics
    

    instead of

    tar -cf pics.tar ./pics
    

    or

    tar --extract --file pics.tar```
    instead of
    

    tar -xf pics.tar

    
    which is honestly way easier to remember... \^\^
  • @[email protected]
    link
    fedilink
    151 year ago

    I don’t think tar is actually hard, we are just in the time where we externalize more information into resources such as Google. Its the same reason why younger people don’t remember routes by name or cardinal direction as much anymore.

    side note: $ tldr is much better than man for just getting common stuff done.

  • @[email protected]
    link
    fedilink
    141 year ago

    The “-“ is often not necessary. I use it as a guide to see how long the person running tar has been using it.

    Example:

    tar -xf file.tar == tar xf file.tar

    • Fushuan [he/him]
      link
      fedilink
      English
      4
      edit-2
      1 year ago

      They are functionally flags though and uniletter flags should be preceded by a ‘-’, so I would still prefer to have the ‘-’ written, because it conforms with the standard.

    • @superbirra
      link
      11 year ago

      yeah, you can also ditch that f

      tar c /etc/passwd > fu.tar

      tar t < fu.tar

      tar x < fu.tar

  • @nucleative
    link
    131 year ago

    I have to Google for this everytime. What I can never remember is how to check whether I should put my tar.gz into the subfolder first or risk getting a thousand files sprayed into my homedir.

    • @SirQuackTheDuck
      link
      11 year ago

      If you have a somewhat decent shell, just smack tab twice after the filename, it’ll list the directories present.

  • @[email protected]
    link
    fedilink
    11
    edit-2
    1 year ago

    I know the basics off by heart. Not the hardest command syntax to learn all things considered.

    The most annoying would be the growing collection of “uber commands” which are much more of a pain in the ass - aws, systemctl, docker, kubectl, npm, cargo, etc. - the executable has potentially dozens of subcommands, each of which has dozens of parameters.

    • stilgar [he/him]
      link
      fedilink
      English
      61 year ago

      These “uber commands” tend to be much better since they are more explorable with --help explanations and readable flags.

      Much better than the random jumble of characters you’re expected to have memorised for awk, sed, find et al.

      • @[email protected]
        link
        fedilink
        41 year ago

        Powershell is horrible all right. What annoys me is they alias ls, dir and other common commands onto commands which don’t act or behave in the same way at all. I just run bash or command prompt rather than deal with the bs of powershell.

      • @tsz
        link
        31 year ago

        I very much disagree, what are you referring to?

  • @[email protected]
    link
    fedilink
    English
    81 year ago

    Yes, that’s all very well, but you’ll still need to find that image the next time you want to use it.

  • 520
    link
    fedilink
    81 year ago

    Simple:

    tar -(whatever options you want here, my go to is xvzf or cvzf) archive-name.tar file/folder-to-compress

      • yyyesss?
        link
        61 year ago

        oh my god, thank you for this

      • 520
        link
        fedilink
        21 year ago

        Oh I’m aware, I’m just saying this is what I normally do with it

        • @[email protected]
          link
          fedilink
          English
          31 year ago

          I’m sorry, I was trying to be silly and poke fun at how most of us just use the one or two tar commands and it totally didn’t translate in text like it did my head. Have a wonderful day good internet stranger.