Linux self-extracting file revision code

Source: Internet
Author: User

Previously wrote a shell automatic decompression program, http://gzinfo.blog.51cto.com/2492370/1416508, in the actual operation found that not all the compressed file appended to the end of the file is just a line, So the previous script is only suitable for cases where there is no line break, it is recommended to use the revised version

Create a new shell named Autoexe.sh, with the following file contents:

#!/bin/bash# define unzip dirddir= '/var/www ' [!-D ${ddir}] && mkdir-p ${ddir}lines=$ (wc-l $0|cut-d "-f1) En dline=$ ((${lines}-10)) Tail-n ${endline} $0> _temp_.zipunzip-o _temp_.zip-d ${ddir}rm _temp_.zip-rfexit

Next, append the zip package file to the end of the autoexe.sh file, and take Test.zip as an example to execute the following command:

Cat test.zip>>autoexe.sh

And then the autoexe.sh through the SCP, lftp and other upload tools to upload to the remote server, and the remote server to perform the autoexe.sh implementation of automatic compression of the file

This article from the "Daily Internet" blog, declined to reprint!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.