Shell command (Try this out!!!!!!!)
Can any body explain what this statement is doing
tar cvf-.|(cd /mnt/loop1 ; tar xvf-) I ll be really greatful as i m not so familiar with shell programming I m not been able to understand , what this statement is doing. I ll be really thankful if someone can shed some light on this |
Haven't actually tried it, but it's fairly simple. '-' as an output filename tells tar to write to stdout. '.' says to archive everything in the current directory.
Without the parentheses, all that junk would be piped into the cd builtin, which would do nothing. With the parentheses, the output from tar is piped into the stdin of the last command, which is another tar. This second tar is waiting for a file on stdin ('-' here means stdin), which it dutifully "extracts" to the new working directory (/mnt/loop1 in this case). It's quite similar to 'cp -r . /mnt/loop1'. There may be some subtle difference that I'm unaware of. Where'd you come across the command :)? Do they offer a rationale for such a method? Or is this homework, and I'm a damned fool. |
Hey
I am trying to build a bootable cd for my system so that i can recover in case of crash. I am a linux developer i mostly work in C/C++ and QT . Shell scripting is not my field . But i came across this command in tutorial for making the CD. but this command is not working for my system (I am on redhat 9). It says "old option f require filename" and exit without doing any thing . and i am kind of struck here. Can you plz tell me its subsitute. I ll be really thankful |
I believe this would work:
tar cvf-.|(cd /mnt/loop1 ; tar xvO) That's a capital o at the end, like after n and before p in the alphabet. Take a look at 'man tar'. |
Hi Thnx for replying but its still not working its giving the error that "Old option 'f' requires an argument ".
Can any body plz explain me why its not working . Is this command trying to zip the contents of current working directory and then unzip the zip contents t o "/mnt/loop1" |
Not 'zip'ing but 'tar'ing. Read the man page ;)
|
You're missing spaces in your command, try:
tar cvf - . | (cd /mnt/loop1 ; tar xvf - ) |
All times are GMT -5. The time now is 12:48 PM. |