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
Shell scripting sreejith SUN Solaris 2 10-08-2006 10:38 AM
difference between AIX shell scripting and Unix shell scripting. haroonec Shell Programming and Scripting 2 04-12-2006 09:12 AM
Help on SED AWK in shell scripting kaushys Shell Programming and Scripting 3 03-09-2006 02:40 PM
Shell scripting sendhil Shell Programming and Scripting 1 02-14-2006 12:16 PM
Shell scripting dipanrc Shell Programming and Scripting 4 10-27-2005 04:53 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-11-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
You are repeating yourself. Try to clarify what should happen.

The way I understand your question is:

1. Your file contains many lines, some of which are names of .gz files. Find those lines.
2. For each found line, unzip the file it names.
3. (Not clear what you mean; unzipping a file will replace it with an uncompressed version already; is that not what you want?)
  #2 (permalink)  
Old 09-12-2008
subhendu81 subhendu81 is offline
Registered User
  
 

Join Date: Sep 2008
Location: mumbai
Posts: 78
hi,


you are absolutely right ....bt i wanna it in somethng different way..

let me clear you the question question with exzmple:

lets say i have a file named "sample". it contains somany lines of data as

/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample.gz
/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample1.gz
/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample2.gz
...
...

i will take the file "sample" as input.after unzipping the output shud be

output:
=====
/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample
/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample1
/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample2
...
...

quick response is appreciable.
  #3 (permalink)  
Old 09-12-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Code:
gunzip $(cat sample)
  #4 (permalink)  
Old 09-12-2008
subhendu81 subhendu81 is offline
Registered User
  
 

Join Date: Sep 2008
Location: mumbai
Posts: 78
my requirement is:

input (lines in the file)
/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample.gz
/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample1.gz
/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample2.gz
...
...

output:
======

/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample
/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample1
/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample2
...
...

i mean i want to replace all the line of the file by these new output lines.
i.e (the line contain sample instead of sample.gz)

Last edited by subhendu81; 09-12-2008 at 01:54 AM.. Reason: to remove the smileys
  #5 (permalink)  
Old 09-12-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Oh, so you don't actually want to perform the gunzip, you just want to remove the .gzs from the file? Just use a sed search-and-replace (see man sed).
  #6 (permalink)  
Old 09-12-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Or if you want to unzip and echo out the resulting unzipped file name, try gzip -dv -- it will print a message for each file (albeit not in a very machine-readable form). Or perhaps try this:

Code:
sed -n 's/\.gz//p' file |
tee outputfile |
while read match; do
  gzip -d "$match".gz
done
This will decompress each matched file and print the file names sans .gz extension to outputfile
  #7 (permalink)  
Old 09-12-2008
subhendu81 subhendu81 is offline
Registered User
  
 

Join Date: Sep 2008
Location: mumbai
Posts: 78
i wanna unzip that files as well as replace the files with .gz extn in main file with normal file(sample.gz to sample).
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 08:01 PM.


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