Compress Files in Multiple Directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Compress Files in Multiple Directories
# 1  
Old 02-13-2017
Compress Files in Multiple Directories

I would like to compress the files in multiple directories. For some reason, it only compress the first directory (/Sanbox/logs1) but not the rest of the other directories ("/Sanbox/logs2" "/Sanbox/logs3" "/Sanbox/logs4" ). Any help would be appreciated. Here's my code:


Code:
#!/bin/bash
LOG_FILES=( "/Sanbox/logs1" "/Sanbox/logs2" "/Sanbox/logs3" "/Sanbox/logs4" )
 
for file in ${LOG_FILES[file]}/* ; do
    gzip "${file}"
done


Last edited by Chubler_XL; 02-13-2017 at 04:56 PM.. Reason: Please use code tags for code blocks not icode
# 2  
Old 02-13-2017
Pleaes re-read this post:

https://www.unix.com/302991442-post5.html

MadeInGermany already answered this same issue in your last thread.
This User Gave Thanks to Chubler_XL For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Compress multiple gzip files

Good afternoon friends. I wanted to make a query, how to compress several files and leave them all in 1, for example flat text files: filename_1.csv filename_2.csv filename_3.csv expected result filename_end.gzip = (filename_1.csv filename_2.csv filename_3.csv) please (2 Replies)
Discussion started by: tricampeon81
2 Replies

2. UNIX for Dummies Questions & Answers

How to compress the directories which is older than 7 days?

Hi all, how to compress the directories which is older 7 days. If any one knows please help me this is urgent. Thanks in advance (3 Replies)
Discussion started by: rameshpagadala
3 Replies

3. Shell Programming and Scripting

Help with zipping files in multiple directories

I'm trying to zip multiple files from within certain directories which are named out. find . -name "*_out -print | xargs zip * I get this error : A file or directory in the path name does not exist how do I get this to work from within my KSH script? (2 Replies)
Discussion started by: Bperl1967
2 Replies

4. Shell Programming and Scripting

perform 3 awk commands to multiple files in multiple directories

Hi, I have a directory /home/datasets/ which contains a bunch (720) of subdirectories called hour_1/ hour_2/ etc..etc.. in each of these there is a single text file called (hour_1.txt in hour_1/ , hour_2.txt for hour_2/ etc..etc..) and i would like to do some text processing in them. Each of... (20 Replies)
Discussion started by: amarn
20 Replies

5. Shell Programming and Scripting

FTP multiple files from multiple directories

I have multiple files that starts as TRADE_LOG spread across multiple folders in the given structure.. ./dir1/1/TRADE_LOG*.gz ./dir2/10/TRADE_LOG*.gz ./dir11/12/TRADE_LOG*.gz ./dir12/13/TRADE_LOG*.gz when I do ftp uisng mput from the "." dir I am getting the below given error mput... (1 Reply)
Discussion started by: prasperl
1 Replies

6. Shell Programming and Scripting

Compress files as per timestamp in multiple subdirectories

I'd really appreciate if anyone could assist me with this code A directory with multiple subdirectories has multiple files which are timestamp'ed. We need to - compress files as per timestamp - save compressed file/s in the respective folder - delete the source files ============... (2 Replies)
Discussion started by: sreewin7
2 Replies

7. UNIX for Dummies Questions & Answers

Compress multiple files at one go

I want to compress all the files which are three years older ..I have thousands of files... 1) This doesnt work find ./ -type f -mtime +1176 -print | xargs -n1 -i tar -cvf {} Errror tar: Missing filenames Probably because of - find ./ -type f -mtime -1 -print returns - " ./temp.txt"... (6 Replies)
Discussion started by: kedar.mehta
6 Replies

8. Shell Programming and Scripting

compress directories with .tar extension

hi guys.. Since am a bit new to shell scripting, can anyone help me with this problem please.. i've been struggling with it since 2 days. :( I have a directory lets say myFolder and within it I have sub directories let say myFolder1.tar, myFolder2, myFolder3, etc. I need to write a shell... (12 Replies)
Discussion started by: kanexxx
12 Replies

9. Shell Programming and Scripting

Compress multiple files

Hi Friends, Can anyone help me out with compressing multiple files. I have multiple files in directory , I have to compress these into a single file, I tried using gzip -r outfile.gz file1 file2 file3. It is not working Thanks in advance for your help S :) (5 Replies)
Discussion started by: sbasetty
5 Replies

10. Shell Programming and Scripting

FTP multiple files to different directories

The script below is written to ftp files to different directories on the destination server, but I'm not sure whether I have written the code correctly or not. Can anyone help me on this? #!/bin/sh FILE_NAMES="FileA FileB FileC" SERVER=xxxx USERID=abcd PASSWD=xxxxx... (12 Replies)
Discussion started by: abrd600
12 Replies
Login or Register to Ask a Question