Announcement

Collapse
No announcement yet.

what is wrong with this tar command?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    what is wrong with this tar command?

    Code:
    sudo tar --create --file=docs.$(date).tar ~/docs/*.*
    I want the tar file to have the creation date in the name regardless of what date the file was made.
    Registered Linux User: 450747<br />Registered Ubuntu User: 16269

    #2
    Re: what is wrong with this tar command?

    not sure what you mean.
    not sure why you use "sudo" either.

    see if this is what you're looking for:
    Code:
    tar --create --file=docs.`date +%Y%m%d%H%M%S`.tar ~/docs/*.*
    "old" syntax (just out of curiosity) would be something like:
    Code:
    tar cvf docs.`date +%Y%m%d%H%M%S`.tar ~/docs/*.*
    hth
    gnu/linux is not windoze

    Comment


      #3
      Re: what is wrong with this tar command?

      Originally posted by jankushka
      not sure what you mean.
      not sure why you use "sudo" either.

      see if this is what you're looking for:
      Code:
      tar --create --file=docs.`date +%Y%m%d%H%M%S`.tar ~/docs/*.*
      That code was exactly what I was looking for (without the H M or S. BTW I used sudo because I was getting permissions errors. I was using it from across volumes/computers. Thanks! 8)
      Registered Linux User: 450747<br />Registered Ubuntu User: 16269

      Comment


        #4
        Re: what is wrong with this tar command?

        Code:
        tar --create --file=docs.`date +%Y%m%d`.tar ~/docs/*.*
        New problem
        How do I tar recursively (ie. all files and folders and sub folders) in the above mentioned directory.
        Code:
        rm -R /docs
        would recursively remove files and folders in a given directory.
        Registered Linux User: 450747<br />Registered Ubuntu User: 16269

        Comment


          #5
          Re: what is wrong with this tar command?

          --recursion
          recurse into directories (the default)
          Windows no longer obstructs my view.
          Using Kubuntu Linux since March 23, 2007.
          "It is a capital mistake to theorize before one has data." - Sherlock Holmes

          Comment


            #6
            Re: what is wrong with this tar command?

            Ahh yes, it is default. But I was putting the "/*.*" which changed the default and specified only files that met that specification. *.* is a nasty DOS habit.
            Registered Linux User: 450747<br />Registered Ubuntu User: 16269

            Comment


              #7
              Re: what is wrong with this tar command?

              Yup. Old habits die hard.

              From the Description of the TAR man page:

              The final arguments to tar are the names of the files or direc‐
              tories which should be archived. The use of a directory name always
              implies that the subdirectories below should be included in the
              archive.
              Windows no longer obstructs my view.
              Using Kubuntu Linux since March 23, 2007.
              "It is a capital mistake to theorize before one has data." - Sherlock Holmes

              Comment


                #8
                Re: what is wrong with this tar command?

                There is no "date" environment variable unless you set it. The `date` command showed above solves at least part of the problem.

                Comment

                Working...
                X