Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Post Need my script to check if compress folder is corrupt or not


    Iím still new to Linux so you have to forgive me, I am trying to compress a folder and the contents within, while keeping the permissions the same. I then need to check if the compress file is corrupt or not. Base on that result I need to transfer the file (I can do that myself)

    Any help would be appreciated

    cd /home/ops/Desktop/temp
    tar cvzfp backup-"$(date +%d-%b-%y)".tar.gz /home/ops/Desktop/dir1
    gunzip -tl backup-"$(date +%d-%b-%y)".tar.gz

  2. #2
    Linux Newbie
    Join Date
    Apr 2010
    Novosibirsk, Russia


    I don't think you need to check TAR's work If there any errors appeared while compressing file, you will see them immediatly at your terminal.

    In general, you can always check the integrity of your original file by calculating its checksum. It looks like you calculate it using `md5sum`command (before compressing), then anyone who uses your file can check it after decompression, using this checksum. Compression looks like some king of encryption where you change binary representation of data. It means that you can't get access to original file in archive without decompression.

  3. #3
    Ok thanks for the advice I manage to find this command of this forum to compare two files

    see below

    diff <(md5sum /home/ops/Desktop/test1/test.txt| awk '{print $1}') <(md5sum /home/ops/Desktop/test3/test.txt | awk '{print $1}')

    if the files match there is no output which if find

    I then change a file on purpose to see what i get which is this

    < b9628c4ab9b595f72f280b90c4fd093d
    > d41d8cd98f00b204e9800998ecf8427e

    How in a bash script would I write something if both files match I get E-mail alert saying the backup was successful and if not E-mail would alert the backup failed. Sorry to ask It's just being new to Linux I just not sure of how the syntax would go.

  4. $spacer_open

Posting Permissions

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