Sometimes you want to preserve only a directory structure into a tar ball without having to archive the files themselves. This can happen if you want to backup a pre-defined directory structure, run some tests, and do not really care about the files created during the test. You can use the UNIX commands ‘find’ and ‘tar’ to do that.
# find bwtest -type d > dirlist.txt
# more dirlist.txt
bwtest
bwtest/dd1
bwtest/dd1/1
bwtest/dd1/458986
bwtest/dd1/217128
bwtest/dd1/217136
bwtest/dd1/217182
bwtest/dd2
bwtest/dd2/2
bwtest/dd3
bwtest/dd3/3
bwtest/reports
# tar -cvf ./bwtest.tar -L dirlist.txt
# more dirlist.txt
bwtest
bwtest/dd1
bwtest/dd1/1
bwtest/dd1/458986
bwtest/dd1/217128
bwtest/dd1/217136
bwtest/dd1/217182
bwtest/dd2
bwtest/dd2/2
bwtest/dd3
bwtest/dd3/3
bwtest/reports
# tar -cvf ./bwtest.tar -L dirlist.txt
content.tar will contain only the directories, no files. This should work on
all UNIX and Linux platforms.
No comments:
Post a Comment