shell 獲取壓縮檔案的解壓進度

2021-10-24 11:39:33 字數 1383 閱讀 8745

#!/bin/bash

# $#表示引數的個數

# $@表示引數內容

# $0表示第幾個引數

# -ne 不等於

if[ $# -ne 2 ]; then

echo

"usage: $0

"exit 1

fitsize=0

for fsize in

$(tar tvvf $1 |

awk'');

doif

["$fsize"

="$"];

then

tsize=

$((tsize+fsize))

fidone

[$tsize -eq 0 ]

&&exit 1

msg=

"extracting..."

remote=

"project"

prog_pos=

$(($+1))

perc_pos=

$(($+

53))

echo

$msg

sendmessage $ 1

prev=-1

nsize=0

for fsize in

$(tar xvvf $1 -c $2 |

awk'');

doif

["$fsize"

="$"];

then

nsize=

$((nsize+fsize))

percent=

$((nsize*

100/tsize))

if[$percent -ne $prev];

then

# plus=$((percent/2))

# progress=$(printf "%.$d" | tr '0' '+')

# echo -e "\e[a\e[$g$=>"

# echo -e "\e[a\e[$g$%"

sendmessage $ 2 -i $

prev=

$percent

fifi

doneif[

$percent -eq 100 ]

;then

sendmessage $ 3

else

sendmessage $ 4

fi

說明:

該指令碼將壓縮檔案解壓至指定位置,並把當前進度傳送給指定程式。

usage: ./myshell.sh 

sendmessage為自編譯的執行命令。

解壓縮檔案

public static fastzip fz new fastzip 壓縮檔案 壓縮檔案的路徑與名稱 被壓縮的檔案路徑 解壓密碼 null代表無密碼 public static string filetozip string zipfilepath,string filepath,string ...

解壓縮檔案

using system using system.collections.generic using system.linq using system.text using system.threading.tasks using system.io namespace commonhelper ...

gzip壓縮檔案 解壓檔案

解壓gzip壓縮格式檔案 eg 123.mms param source 原始檔 param target 目標檔案 public static void ungzipfile file source,string target throws exception gzin.close 關閉壓縮輸入流...