shell scripting

i wanna unzip that files as well as replace the files with .gz extn in main file with normal file(sample.gz to sample).

Does the small script above not satisfy your requirements?

it meets my requirement...and thanks for that..

but i want 2 use the resulted output file in a for loop...

let me explain u clearly...

now i have the output file with data:

/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 want to take the output file in a for loop ...
means for 1st iteration of the loop it does the change(replacement of something by using sed) for the file sample and then
it does for sample1 and so on......

can u plz help me regarding this?

thanks..

subhendu

sed -n 's/\.gz//p' file |
while read match; do
  gzip -d "$match".gz
  echo "$match"
done | further processing on file names without .gz suffix

Though, you probably want to do the other loop inside this loop, where I have "echo $match", instead of feeding it to another while (not for) loop.

(echo list; echo of; echo things; ) | while read stuff; do ... is equivalent to for stuff in list of things; do ... with the added benefit that whitespace in any item in the list of things won't cause breakage, and the list of things is part of the pipeline instead of the command line (this matters when the list is really long).

still it is not working.....

i am sending u that in that zip file ...and what i want 2 do.

sample.gz contains dat:

a;"as;";cd

sample1.gz contains data:

c;d;e;"a;";"d;";f

and so on.....

i want 2 delete the delimiter within double quotes and printed the data file with extn .new (i.e sample.new ,sample1.new and so on.....)

after deletion the data in the file shud be

a;"as";cd for sample.gz and so on....

hence the script shud do the following things:

1.first unzip the files and redirect into a file
2.then the unzip file is taken as input to delete the delimiter within double quotes iin respective files...
3.shud create new file for each one with extn (.new).

kindly help me ASAP.

can u please help me to write the script?

please don't "bump" up your questions. read the rules of unix.com. thnx...

So sample.gz should be unzipped into sample, and sample1.gz should be unzipped into sample1, etc?

Additionally, sample.new should contain the modified contents of the unzipped sample file, and sample1.new should contain the modified contents of the unzipped sample1 file?

Is it sufficient to replace any occurrence of ;"; with "; to produce the modified data? If so, try the following:

sed -n 's/\.gz//p' file |
while read match; do
  gzip -d "$match".gz
  sed 's/;";/";/g' "$match" >"$match".new
done

it is not working for sample1.gz as it contains more than one record in that file.

You will have to show us the actual data in sample1.gz and the output you expect for us to fully understand your requirement.

let the file name is test.dat


cat test.dat | cut -d"/" -f10

it will only work if source zip files are stored in a single directory..