美文网首页
shell实现自解压文件

shell实现自解压文件

作者: 白鳥白鳥 | 来源:发表于2018-08-13 11:27 被阅读0次

以 tar.bz2 为例:

$ cat test

Alice comes upon a mushroom and sitting on it is a blue Caterpillar smoking a
hookah. The Caterpillar questions Alice and she admits to her current identity
crisis, compounded by her inability to remember a poem. Before crawling away,
the caterpillar tells Alice that one side of the mushroom will make her taller
and the other side will make her shorter. She breaks off two pieces from the
mushroom. One side makes her shrink smaller than ever, while another causes
her neck to grow high into the trees, where a pigeon mistakes her for a serpent.
With some effort, Alice brings herself back to her normal height. She stumbles
upon a small estate and uses the mushroom to reach a more appropriate height.

$ tar jcf test.tbz2 test

写入 shell 脚本,并将数据放入 exit 0 之后:

$ lines=`echo '1,p\nq' | vim -e test.tbz2 | wc -l`
$ cat > 1.sh << EOF
> #!/bin/bash
> start_line=7
> end_line=$((7+$lines-1))
> sed -n \$start_line','\$end_line'p' \$0 | head -c -1 | bzcat
> exit 0
> 
> EOF
$ cat test.tar.bz2 >> 1.sh
$ echo "\n" >> 1.sh
$ chmod +x 1.sh
$ rm test.tbz2
$ ./1.sh

相关文章

  • shell实现自解压文件

    以 tar.bz2 为例: Alice comes upon a mushroom and sitting on ...

  • Shell 中利用FIFO实现多进程tar解压的方法

    上文Shell中使用tar命令批量解压缩的实现方法中提到我使用循环的方法批量解压tar文件,但是单进程的解压耗时太...

  • 11月1日

    今天继续学习shell指令 主要是链接文件创建 与文件的压缩与解压 理解什么是硬链接与软链接 重点是压缩文件与解压...

  • Shell自动交互脚本

    Shell 自动交互教程 @(TeachOfShell) 实现了:目前实现了shell文件上传以及基于docker...

  • 终端用shell读写plist文件

    【原帖置顶】shell文件中读取plist文件并实现shell中的数值计算 Mac操作plist文件用PlistB...

  • 批量解压zip

    利用shell命令for和unzip命令,批量解压查找当前目录下的zip文件,并创建zip同名目录,然后解压到目录

  • 01-替换jar包中文件或jar文件

    1 替换指定配置文件 linux的shell环境下,找到配置文件所在路径 解压出配置文件 修改配置文件后,将配置文...

  • php文件上传

    单文件上传实现: 文件上传代码参考:文件上传 多文件上传实现: 前台调用: shell方式 浏览器方式: 后台处理...

  • Kotlin 协程Demo,实现预制脚本

    使用Kotlin 实现多协程同时下载文件,充分利用IO Kotllin协程解压文件 14个文件 解压耗时1412ms

  • Android 解压Zip以及进度回调

    一、实现一个回调状态的接口 二、获取zip文件的大小 三、解压文件,回调状态 四、通过以上的步骤就可以实现解压zi...

网友评论

      本文标题:shell实现自解压文件

      本文链接:https://www.haomeiwen.com/subject/wfuybftx.html