Stripping and Renaming parent directory for each line output in tar -T -?
1
vote
0
answers
33
views
I have an list of directory output from the following command that I want to tar:
find ./temp -type f -name '*'
./temp/main/randomfile.txt
./temp/main/dir_a/random.txt
./temp/main/dir_b/random.txt
./temp/main/dir_c/random.txt
Then I pipe the result:
tar -zchf ./tars/randomtar.tar.gz -T -
Combined commands:
find ./temp -type f -name '*' | tar -zchf ./tars/randomtar.tar.gz -T -
This will take each result from the output and tar into randomtar.tar.gz
How do I change the parent directory of each output from find
command when compressing?
When I untar the file, I would get:
./temp/main/randomfile.txt
./temp/main/dir_a/random.txt
./temp/main/dir_b/random.txt
./temp/main/dir_c/random.txt
I want to get this result when I untar:
./new_parent_name_main/randomfile.txt
./new_parent_name_main/dir_a/random.txt
./new_parent_name_main/dir_b/random.txt
./new_parent_name_main/dir_c/random.txt
Asked by vcoder_12
(11 rep)
Jun 25, 2021, 04:57 PM
Last activity: Jun 27, 2021, 03:16 PM
Last activity: Jun 27, 2021, 03:16 PM