shell scripting

hi experts,
how can i separate the files contaiing several lines as
/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample.gz
/common/interface/inbound/na/data/pre-receive/gadtest/subhendu/sample1.gz

i mean i want 2 separate the files sample.gz and sample1.gz and redirect them into an output file.

can u please help me reagrding this?

Immediate response is appreciable.

Subhendu, Can you please tell what actually you mean saying "separate".

An elaborate problem description would help the forum to help you.

i just want to cut the filenames sample.gz and sample.gz from the file which contains absolutepath and file name.

you can use

hope this will work

actually i want 2 cut the file names for record more than 30000....so i cann't specify partcular file names to use grep command.

can u plz tell me the way 2 cut the file names for a large file?

well put all the matching patterns in single file say pattern.dat

then you can use following

you can manipulate contents of pattern.dat and get matchings accordingly

my requirement are:

1.i have to find the zip files from the file
2.unzip all the files
3.again save the unzipfiles with absolute path which is defined in that file.

how can i make pattern file for file containing morethan 30000 records....its not possible

can u plz tell me in details...

grep '\.gz$' file |
while read match; do
  gzip -d "$match"
  # unclear what you mean by "absolute path which is defined in that file" ...
  # defined how, in which file?
done

That is not working......

hi experts,
how can i separate the files contaiing several lines 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 mean i want 2 cut the files sample.gz and sample1.gz and redirect them into an output file.

my requirement are:

1.i have to find the zip files from the file
2.unzip all the files
3.again save the unzipfiles with absolute path which is defined in that file.

hi,
how can i separate the files contaiing several lines 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 mean i want 2 cut the files sample.gz and sample1.gz and redirect them into an output file.

my requirement are:

1.i have to find the zip files from the file
2.unzip all the files
3.again save the unzipfiles with absolute path which is defined in that file.

It's not alllowed to bump questions!

Please read our rules.

k...ll tk care of that

i m writting th requirement in detail...

so posting the query in this way..

hi,
how can i separate the files contaiing several lines 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 mean i want 2 cut the files sample.gz and sample1.gz and redirect them into an output file.

my requirement are:

1.i have to find the zip files from the file
2.unzip all the files
3.again save the unzipfiles with absolute path which is defined in that file.

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?)

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.

gunzip $(cat sample)

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)

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).

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:

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