星空网 > 软件开发 > 操作系统

linux下的单文件安装程序——shell+tar实现自解压脚本

1. 先编辑一个解压脚本ins.sh

  1 #!/bin/bash

  2 preline=10
  3 line=`wc -l $0|awk '{print $1}'`
  4 line=`expr $line - $preline`
  5 tail -n $line $0 |tar xz -C ./
  6 #do something...
  7 exit 0
  8 
  9 
 10 

 11 

前5行用于解压,最后用空行补齐,总行数=preline+1,解压用的tar xz,故压缩需要cz

 

2. 制作压缩包

tar cvzf xxx.tgz xxx/

 

3. 拼接文件

cat ins.sh xxx.tgz > install.sh

chmod +x install.sh

 




原标题:linux下的单文件安装程序——shell+tar实现自解压脚本

关键词:linux

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

voghion入驻条件:https://www.goluckyvip.com/tag/27047.html
传统制造转型:https://www.goluckyvip.com/tag/2705.html
voghion怎么入驻:https://www.goluckyvip.com/tag/27052.html
Voghion账号:https://www.goluckyvip.com/tag/27053.html
Voilà:https://www.goluckyvip.com/tag/27055.html
volcaneestore:https://www.goluckyvip.com/tag/27056.html
九月初新疆旅游服装搭配(新疆游玩必备衣服清单):https://www.vstour.cn/a/408257.html
黄果树瀑布景区景点 - 黄果树瀑布景区景点分布图:https://www.vstour.cn/a/408258.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流