This website mentions using the -p command, but this creates security issues.
https://www.linuxquestions.org/questions/linux-general-1/bin-tar-removing-leading-`-'-from-member-names-269508/
This creates tar file will a full path of folders, including the username. I want only the folder to click on when opening the tar file. Need help.
‘TestFolder’ is copied into the user folder.
User_Folder='/home/username'
tar -zcvf "${User_Folder}/TestFile.tar.gz" "${User_Folder}/TestFolder'
Hi
Use the -C option;
tar -zcvf /home/username/TestFile.tar.gz -C /home/username/TestFolder .
./
./stderrdae.txt
./stderrgpudetect.txt
./stdoutdae.txt
./stdoutgpudetect.txt
tar -tf TestFile.tar.gz
./
./stderrdae.txt
./stderrgpudetect.txt
./stdoutdae.txt
./stdoutgpudetect.txt
tar -zcvf "${User_Folder}VirusFound.tar.gz" -C "${User_Folder}VirusFound"
Compress folder → VirusFound.tar.gz /home/username
tar: Cowardly refusing to create an empty archive
This is the code being used. Isolating by removing the var names helped. The basic line:
tar -zcvf "/home/username/VirusFound.tar.gz" -C "/home/username/VirusFound"
This didn’t work, but I think I understand why.
printf "Compress folder --> VirusFound.tar.gz
"
tar -zcvf "${User_Folder}VirusFound.tar.gz" -C "${User_Folder}" VirusFound
This code works. That completes another handy function for scanvirus.
Thanks malcolmlewis.
Will this tar file with ms windows?
Hi
It should do… else switch to zip…
Thanks, unless other information is found. I’ll just use tar with gzip.
End topic…