1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Using SSH to Zip files

Discussion in 'Site & Server Administration' started by EnDLeSs_27, Dec 8, 2008.

  1. #1
    Does anyone know how I would zip up an entire directory's files one by one with one command?

    For instance. If the directory has 200 files how would I zip each one separately using ssh.
     
    EnDLeSs_27, Dec 8, 2008 IP
  2. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #2
    find . -type f -exec zip '{}.zip' '{}' \;
    Code (markup):
     
    joebert, Dec 8, 2008 IP
  3. ravee1981

    ravee1981 Active Member

    Messages:
    712
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    60
    #3
    tar.gz is better for linux

    so, to compress

    tar -cvzf filename.tar.gz /home/path
    Code (markup):
    and to decompress

    tar -xvzf filename
    Code (markup):
     
    ravee1981, Dec 11, 2008 IP
  4. EnDLeSs_27

    EnDLeSs_27 Active Member

    Messages:
    112
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Worked like a charm ;] Thanks
     
    EnDLeSs_27, Dec 11, 2008 IP
  5. compevo

    compevo Member

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    33
    #5
    I agree tar is better for Linux.
     
    compevo, Dec 12, 2008 IP
  6. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #6
    zip is user friendly for a wider audience than tar/rar/etc.
    In any event, if you want to gzip each file individually rather than zip them.

    find . -type f -exec tar -cvzf '{}.gz' '{}' \;
    Code (markup):
     
    joebert, Dec 12, 2008 IP