943,899 Members | Top Members by Rank

Ad:
May 27th, 2009
0

Have I got this right? tar command.

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
scottyscotty19 is offline Offline
22 posts
since Nov 2008
May 28th, 2009
0

Re: Have I got this right? tar command.

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:
Shell Scripting Syntax (Toggle Plain Text)
  1. tar cvf /dev/nrst0 /usr/local/bin
  2. tar cvf - /usr/local/bin | dd of=/dev/nrst0 bs=1024k
  3. 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.)
Reputation Points: 51
Solved Threads: 35
Posting Whiz in Training
Fest3er is offline Offline
238 posts
since Aug 2007
May 28th, 2009
0

Re: Have I got this right? tar command.

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
scottyscotty19 is offline Offline
22 posts
since Nov 2008
May 28th, 2009
0

Re: Have I got this right? tar command.

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.
Reputation Points: 51
Solved Threads: 35
Posting Whiz in Training
Fest3er is offline Offline
238 posts
since Aug 2007
Jun 2nd, 2009
0

Re: Have I got this right? tar command.

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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
versatileint is offline Offline
6 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: Using Multiple Arguments in Bash Script
Next Thread in Shell Scripting Forum Timeline: Automated ssh with top





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC