LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   tar dir and sub dir removing files but not existing not empty dir (https://www.linuxquestions.org/questions/linux-general-1/tar-dir-and-sub-dir-removing-files-but-not-existing-not-empty-dir-4175473114/)

j-me 08-12-2013 11:06 AM

tar dir and sub dir removing files but not existing not empty dir
 
have the need to tar a directory with several sub directories /files removing the files but retain all directories. the code I am using works great at tar gzip files but also removes the entire directory structure.

Code:

tar -zcPf ~/temp/archive_folders.tgz /mnt/bus_pc/qhoesb04 --remove-files
I have read and searched for some time and have not found a solution.

thank you

Firerat 08-12-2013 11:27 AM

after your tar, use find to find just the files

e.g.
Code:

tar -zcPf ~/temp/archive_folders.tgz $(find /mnt/bus_pc/qhoesb04 -type f) --remove-files
this works because you are only giving tar a list of files, not files and dir.

j-me 08-12-2013 11:37 AM

thank you. that worked great!!


All times are GMT -5. The time now is 06:30 PM.