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