Tar.gz/zip folders in a directory with _EBASE string

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Tar.gz/zip folders in a directory with _EBASE string
# 1  
Old 03-24-2017
Tar.gz/zip folders in a directory with _EBASE string

Hi Folks -

Happy Friday and I hope you all are well!

What's the easiest way to tar.gz / zip all direct children directories in a folder that have the string _EBASE (suffix)?

Thank you!
# 2  
Old 03-24-2017
Do you want single archive file or one for each directory?
# 3  
Old 03-24-2017
If you could provide both options that would be great. Else, just a single directory to house all of them would be fine.

Thank you!
# 4  
Old 03-24-2017
This is somewhere cpio works better than tar, as tar has a hard time reading in arbitrary lists of files / folders, while cpio always does that.

Code:
find . -mindepth 1 -maxdepth 1 -type d -name '*_EBASE' -print | cpio -ov -H tar | gzip > archive.tar.gz

This User Gave Thanks to Corona688 For This Post:
# 5  
Old 03-24-2017
Thank you so much!

Can i specify a directory or can we only search the entire directory tree?
# 6  
Old 03-24-2017
Replace . with the directory you want.
# 7  
Old 04-04-2017
Hi Folks -

Sorry for the delay - I'm sut getting around to work on this finally.

It seems to work, but getting an error saying file name too long with cpio:

Quote:
cpio: /u01/app/Oracle/Middleware/user_projects/epmsystem1/import_export/Reporting_Analysis_Automation_Base/: file name too long
/u01/app/Oracle/Middleware/user_projects/epmsystem1/import_export/FDMEE_Automation_Base/
/u01/app/Oracle/Middleware/user_projects/epmsystem1/import_export/PLN_HC_Automation_Base/
4 blocks
What is the best course of action?

Thanks!

---------- Post updated at 12:07 PM ---------- Previous update was at 10:58 AM ----------

I got it using this:

Code:
find ${_PROC_EXP_PATH} -type d -name "*_Base" | tar -P -zcvf ${_PROC_PREP_PATH}/LCM_Exports_${_DATETIMESTAMP} -T -

Thank you again!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Gunzip,grep and zip across folders in a subdirectory

I have a simple function that greps within a folder into files that are already gunzipped. This was already written for me so from my understanding fn=$1 specifies that it will look into any file in that folder that is gunzipped and the rest of the script greps the data its looking for and puts it... (3 Replies)
Discussion started by: red56
3 Replies

2. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

3. Shell Programming and Scripting

How to auto zip all folders?

Hi, How do I write a script that will automatically find and zip any folder to the same name in a directory and affected recursively?. The zip file should be place in the same directory where the source folder is. Help is appreciated. Thanks in advance. ex: Orange Crayon Blue Crayon... (5 Replies)
Discussion started by: Frozen77
5 Replies

4. Shell Programming and Scripting

Copy Folders and ZIP IT

HI All I have one master folder : ABCXYZ I have sub folder in there : AB XY AZ AC PR AL Now i want to copy AB , PR ,AL in to one new folder and zip it with time stamp. like Pre_02192013_12_32.zip Zip folder should be in master folder. (2 Replies)
Discussion started by: pareshkp
2 Replies

5. UNIX for Dummies Questions & Answers

TAR and ZIP files

Hi, I need a help with zip and tar. I have no done any scripts before with zip command. What I need to achieve is list files in a directory with a specific name (ID_DATE format- given examples) and then zip (or gunzip which I need to use, I am not sure) with timestamp on the file name and then... (15 Replies)
Discussion started by: Vijay81
15 Replies

6. Shell Programming and Scripting

Help with auto-detect new files/folders then zip and move script

Hello, I need a simple script to Auto-detect new files and folders in the directory. And then I need to zip the new files and bzip2 new folders and move them out of that folder where I am detecting changes to the other folder. Remember, I need simple one. If anyone could do it fast, I may... (1 Reply)
Discussion started by: juzt1s
1 Replies

7. UNIX Desktop Questions & Answers

Using Tar Zip

Hi, I want to backup my SQL database using tar zip but I'm paranoid that I will archive it. What I mean is I want the files to stay where they are but make a zipped copy of the files as well, I don't want to delete the originals. Is the command? tar -cvzf databasename.tar.gz... (1 Reply)
Discussion started by: chickenhouse
1 Replies

8. UNIX for Dummies Questions & Answers

Zip a folder including its sub-folders.

Hi, I have a folder that contains a few sub-folders. I would like to zip that folder and KEEP the subfolders. What it does at the moment is taking all the files within the subfolders and zipping them into one big file (zip -r ...). Does anyone know the UNIX command to keep the subfolders in the... (3 Replies)
Discussion started by: gdog
3 Replies

9. UNIX for Dummies Questions & Answers

tar.gz zip file.....

Hi, i have tar.gz file in inbound director. i want display the contents on the tar.gz file in a temp file. please help me on this. (4 Replies)
Discussion started by: koti_rama
4 Replies

10. UNIX for Dummies Questions & Answers

zip nesting empty folders

I'm using the following command to zip a project file, but when it finishes, the resulting zip file contains all the directories above the file I wanted zipped, myapp.app, each one empty until you get to the actual app. zip -r myapp.app.zip ... (0 Replies)
Discussion started by: groundlevel
0 Replies
Login or Register to Ask a Question