Solved

Explanation for bash code using tar

Posted on 2014-03-11
4
362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 35

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 35

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 35

Expert Comment

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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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