Find the answer to your Linux question:
Results 1 to 7 of 7
I'M working through a Linux book and it's showing how to use tar, the book uses CentOS. I was told to use the command: Code: tar -cf demofile.tar file1.txt file2.txt ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Dec 2010
    Posts
    122

    tar -cf


    I'M working through a Linux book and it's showing how to use tar, the book uses CentOS. I was told to use the command:

    Code:
    tar -cf demofile.tar file1.txt file2.txt file3.txt
    the book also stated that this would create the archive demofile.tar including the file file1.txt, file2.txt, and file3.txt

    After typing this in this is what I got:

    [root@localhost demo]# tar -cf demofile.tar file1.txt file2.txt file3.txt
    tar: file1.txt: Cannot stat: No such file or directory
    tar: file2.txt: Cannot stat: No such file or directory
    tar: file3.txt: Cannot stat: No such file or directory
    tar: Exiting with failure status due to previous errors


    Thanks for any and all replies.

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,211
    Have you actually created those files? If you have, then they don't seem to be in the directory you are working in.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  3. #3
    Administrator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,864
    Hazel is correct. The book is using file1.txt file2.txt file3.txt as examples and you should substitute those examples with files that you have created for this exercise. You can use the same names as the examples or you can change them, just be sure to adjust your command if you do change the name of the examples.
    I do not respond to private messages asking for Linux help, Please keep it on the forums only.
    All new users please read this.** Forum FAQS. ** Adopt an unanswered post.

    I'd rather be lost at the lake than found at home.

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Also, one thing I have learned is, the Linux userland tools are usually pretty good at telling you why they are unhappy (versus Windows ones, for example). You just have to get good at figuring out some of the "short-hand" they use some times. In other words, the tar command is telling you, as it iterates over each file, that it cannot find it (it uses an underlying "stat" function).

    This is why you'll always see us on the boards telling people with problems to please post any error messages they received (which you wisely already did!).

  5. #5
    Linux Newbie
    Join Date
    Dec 2010
    Posts
    122
    It worked after I created the file. I thing is, the Linux book I'M reading was telling me that the command would create the files if they did not already exist.

  6. #6
    Administrator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,864
    Well, either the book is wrong, outdated or you misunderstood it. I'm not much of a programmer but I see nothing in that command that would create those files for you.
    I do not respond to private messages asking for Linux help, Please keep it on the forums only.
    All new users please read this.** Forum FAQS. ** Adopt an unanswered post.

    I'd rather be lost at the lake than found at home.

  7. #7
    Administrator jayd512's Avatar
    Join Date
    Feb 2008
    Location
    Kentucky
    Posts
    5,023
    @Garrett85:
    It worked after I created the file.
    Since you mention a file (singular), what filename did you create?
    ...the command would create the files if they did not already exist.
    And what filenamess did you expect to be created?

    I just want to make sure that we're all on the right path.
    Jay

    New users, read this first.
    New Member FAQ
    Registered Linux User #463940
    I do not respond to private messages asking for Linux help. Please keep it on the public boards.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •