Solved

Explanation for bash code using tar

Posted on 2014-03-11
4
359 Views
Last Modified: 2014-03-11
Question:

Using the tar utitlity, give the specific command(s) you would use to move files a, b, and c from directory
/users/student/rios to /etc/tmp
 

Answer:
( cd /users/student/rios && tar cf - a b c) | (cd /etc/tmp && tar xvpf - )

Open in new window


can someone tell me what tar cf does and why we need the &&. also does the  | mean we are moving the items to the left? why the xvpf - ?

thanks
0
Comment
Question by:Mark_Co
  • 3
4 Comments
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39921374
&& will do the second action only if the first action returns 0 - which means the action was successful

tar x wil e(x)tract the files. v is usually from verbose.

| will pipe the output of the left command to the command on the right

HTH,
Dan
0
 
LVL 34

Assisted Solution

by:Dan Craciun
Dan Craciun earned 500 total points
ID: 39921389
Look at the man page for tar here: http://unixhelp.ed.ac.uk/CGI/man-cgi?tar

c - create
x - extract
v - verbose
p - preserve permissions
f - file
0
 

Author Closing Comment

by:Mark_Co
ID: 39921606
Much obliged
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39921610
Glad I could help!
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question