Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compress Files in Unix using *.sh from *.sh

Status
Not open for further replies.

saw15

Technical User
Jan 24, 2001
468
US
Using Unix and rather new..

I am creating multiple *.txt extracts from oracle and then ftp'ing them to another server. I would like to compress or zip all of the files prior to ftp'ing from Unix to NT, but am not quite sure how to setup the *.sh file.

It seems that I could simply write:

compress file1
compress file2
etc .. to file 25

in a *.sh script.

Any help .. (an example would be great) is much appreciated.

I will be calling this *.sh from another *.sh (in case that matters).

Thanks again.
 
put all the files in their own sub-directory. then a little for loop...

for FILE in `ls` ; do
compress $FILE
done


crowe
 
You can use gzip to compress all your files.

Code:
gzip *.txt

Then WinZip can be used on the NT side.

With compress, you can try this:
Code:
compress -f *.txt
 
Thanks for the assistance..

Crowe.. quick question, I would like to use the looping method and would like some clarification if you can provide it.

I am calling the test.sh script from one directory, In this test.sh script, I will do the loop:

for file in 'ls'; do
compress $FILE
done

My question is such .. the files are actaully in another directory specified by the variable exppath. Do I need to specify the variable or path in prior to the 'ls'? Or in the 'ls' statement?

Again.. thanks.
 
for file in 'ls /correct/path/' Mike
______________________________________________________________________
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
MikeLacey is right on. Within the 'ls' statement.

crowe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top