LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 06-22-2004, 01:09 AM   #1
vbhatia_81
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
rkef
Member
 
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
vbhatia_81
LQ Newbie
 
Registered: Jun 2004
Posts: 13

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

Rep: Reputation: 59
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
vbhatia_81
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
wpyh
Member
 
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
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

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

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


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:51 PM.

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