The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
please explain the below mail2sant Shell Programming and Scripting 1 04-04-2008 08:04 AM
Please can any one explain this ${0##/} gadege Shell Programming and Scripting 2 04-01-2008 03:26 PM
Can anyone explain plz r_W213 UNIX for Advanced & Expert Users 3 03-27-2007 04:52 AM
if [ $? -eq 0 ] .. can someone explain this? ranjita.c Shell Programming and Scripting 5 10-03-2006 07:50 PM
Explain awk hitmansilentass Shell Programming and Scripting 4 09-27-2006 02:14 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-03-2008
avikal avikal is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 1
Exclamation explain plz

can u explain this step by step........plz...will it do the same

for I in *.tar.gz; do
A=`basename $I .tar.gz`
mkdir $A
cp marking-guide ${A}/$A
cd $A
gunzip -c ../$I | tar xf -
cd..
done


thnx
__________________
  #2 (permalink)  
Old 04-03-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink Here is some of it anyway

# loop thru all zip file archives (files ending .tar.gz)
for I in *.tar.gz; do
# set var A to whatever is before the .tar.gz
A=`basename $I .tar.gz`
# make a directory for the var A
mkdir $A
# copy file marking-guide to __
cp marking-guide ${A}/$A
# change directory to A
cd $A
# unzip __
gunzip -c ../$I | tar xf -
# change directory to one back
cd..
# done with loop
done
  #3 (permalink)  
Old 04-03-2008
ShawnMilo ShawnMilo is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 252
For each filename ending in .tar.gz (gzipped tar file)
for I in *.tar.gz; do

Filename without any path (including the .tar.gz)
A=`basename $I .tar.gz`
Make a directory with the same name as the file
mkdir $A
Copy something called marking-guide into the new directory with the same name as the .tar.gz file
cp marking-guide ${A}/$A
Move into the directory and decompress the file
cd $A
gunzip -c ../$I | tar xf -
Go back to the original directory in case there are more iterations of the loop
cd..
done
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0