Results 1 to 5 of 5

Thread: tar gzip on folder giving error - creating folder full path not folder only

  1. #1

    Default tar gzip on folder giving error - creating folder full path not folder only

    This website mentions using the -p command, but this creates security issues.

    https://www.linuxquestions.org/quest...-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.

    Code:
    User_Folder='/home/username'
    tar -zcvf "${User_Folder}/TestFile.tar.gz" "${User_Folder}/TestFolder'

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,707
    Blog Entries
    15

    Default Re: tar gzip on folder giving error - creating folder full path not folder only

    Hi
    Use the -C option;

    Code:
    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
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  3. #3

    Default Re: tar gzip on folder giving error - creating folder full path not folder only

    Quote Originally Posted by malcolmlewis View Post
    Hi
    Use the -C option;

    Code:
    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
    Code:
    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:

    Code:
    tar -zcvf "/home/username/VirusFound.tar.gz" -C "/home/username/VirusFound"
    This didn't work, but I think I understand why.

    Code:
    printf "Compress folder --> VirusFound.tar.gz\n"
    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?

  4. #4
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,707
    Blog Entries
    15

    Default Re: tar gzip on folder giving error - creating folder full path not folder only

    Quote Originally Posted by lord_valarian View Post
    Code:
    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:

    Code:
    tar -zcvf "/home/username/VirusFound.tar.gz" -C "/home/username/VirusFound"
    This didn't work, but I think I understand why.

    Code:
    printf "Compress folder --> VirusFound.tar.gz\n"
    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...
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  5. #5

    Default Re: tar gzip on folder giving error - creating folder full path not folder only

    Thanks, unless other information is found. I'll just use tar with gzip.

    End topic...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •