hi. Does this command (tar cvf /usr/local/bin) create a tape achieve in /usr/local and then copies all the files and directories that are in the /bin directory into the tape archive that is stored in /usr/local?

If not then how does it work? I have looked around the internet and that's the answer that I came up with.

Cheers

hi. Does this command (tar cvf /usr/local/bin) create a tape achieve in /usr/local and then copies all the files and directories that are in the /bin directory into the tape archive that is stored in /usr/local?

If not then how does it work? I have looked around the internet and that's the answer that I came up with.

Cheers

No. Double-check the man page. You'll see the 'f' option requires a value, specifically the name of the destination tar is to use. (UNlike many commands, tar doesn't require that 'f's value follow it immediately; this, of course, makes it a little harder to understand until your neural pathways become accustomed to the pattern.

Assuming your tape device is /dev/nrst0, the following three lines commands are 'equivalent', though the final result is not necessarily the same:

tar cvf /dev/nrst0 /usr/local/bin
tar cvf - /usr/local/bin | dd of=/dev/nrst0 bs=1024k
tar cvf /tmp/ulb.tar /usr/local/bin; dd if=/tmp/ulb.tar of=/dev/nrst0 bs=1024k

All three commands get the tar file to the tape, but do it differently. (Aside, depending on the underlying system, the first command may set the tape drive to use 10KB blocks, while the latter two may set it to use 1MB blocks; this can affect tape portability.)

Hi. Thanks for your answer, but I'm doing some revision and that command is on one of the past papers so it most work. I was just hoping that I understood it how it worked correctly.

OK. Tar is weirder than I thought. If GNU tar is called as 'tar cv /usr/local/bin', it will create a tar archive on STDOUT, seemingly in violation of the man page. Called as you indicated in your first post, it will respond with, "tar: Cowardly refusing to create an empty archive..." I don't know how other flavors and dialects of tar behave. In 20+ years of using tar, I've never encountered a version that works with what you provided.

If you give such a cmd on HP-UX it will say :
tar: usage tar [-]{txruc}[eONvVwAfblhm{op}][0-7[lmh]] [tapefile] [blocksize] [[-C directory] file] ...

and on AIX it will say:
tar: /usr/local/bin : Cannot write to a directory.

Fest3er has given good examples of using tar.
tar cvf <archive_name> <file_or_directory_to be archived> thats the syntax for tar

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.