Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-22-2004, 01:09 AM   #1
LQ Newbie
Registered: Jun 2004
Posts: 13

Rep: Reputation: 0
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
Old 06-22-2004, 01:40 AM   #2
Registered: Mar 2004
Location: bursa
Posts: 110

Rep: Reputation: 15
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.
Old 06-22-2004, 04:10 AM   #3
LQ Newbie
Registered: Jun 2004
Posts: 13

Original Poster
Rep: Reputation: 0
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
Old 06-22-2004, 08:53 AM   #4
Senior Member
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 58
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'.
Old 06-23-2004, 12:41 AM   #5
LQ Newbie
Registered: Jun 2004
Posts: 13

Original Poster
Rep: Reputation: 0
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"
Old 06-23-2004, 01:54 AM   #6
Registered: Jun 2004
Location: Beijing
Distribution: Slackware 9.1 but FUBAR with packages I compile myself, and OpenBSD (not exactly a distro) on QEMU
Posts: 153

Rep: Reputation: 35
Not 'zip'ing but 'tar'ing. Read the man page
Old 06-23-2004, 02:43 AM   #7
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,570

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
You're missing spaces in your command, try:

tar cvf - . | (cd /mnt/loop1 ; tar xvf - )


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
command to go up a level in the shell dr_zayus69 Linux - Newbie 3 01-06-2005 03:36 PM
Shell Command rakriege Linux - General 1 10-04-2004 04:21 PM
what is the shell command to.... praefex Linux - Newbie 2 08-18-2003 05:25 PM
shell command i_is_cat Linux - General 1 08-13-2003 03:09 AM
QT --how to do a shell command linuxlah Programming 2 08-22-2002 02:27 PM

All times are GMT -5. The time now is 11:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration