LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-12-2013, 11:06 AM   #1
j-me
Member
 
Registered: Jan 2003
Location: des moines, ia
Distribution: suse RH
Posts: 129

Rep: Reputation: 17
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
 
Old 08-12-2013, 11:27 AM   #2
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
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.
 
Old 08-12-2013, 11:37 AM   #3
j-me
Member
 
Registered: Jan 2003
Location: des moines, ia
Distribution: suse RH
Posts: 129

Original Poster
Rep: Reputation: 17
Thumbs up

thank you. that worked great!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
include ,h files from dir inside dir knobby67 Programming 1 02-02-2011 06:06 AM
Removing a Specific Dir From All /home Dir carlosinfl Linux - General 4 06-09-2008 01:08 PM
Remove Certain Files/Dir from Large Dir thomas.beaver Linux - Newbie 2 01-27-2008 08:47 AM
Command to display /dir, /dir/sub, /dir/sub/files knockout_artist Linux - Newbie 9 10-25-2007 02:57 PM
Q. moving /bin dir files to /dev dir?? Texas_student Linux - Software 2 03-26-2006 11:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration