Shell decompression package, the sum of all the text of the packet under the recording duration

Source: Internet
Author: User

#!/bin/bash
#from为压缩包批次所在目录
#basetarpath to count the total length of time per batch
From=$1
Basetarpath=$2
suffix= "Tgz"
Todir= $basetarpath
outdir= $basetarpath/home/iflytek/out
if [!-d? $from]; Then
Exit
Fi
if [!-D $basetarpath];then
Mkdir-p $basetarpath
Fi
function Jieya () {
? ? for element in ls $1
? ? Do??
? ? ? ? Dir_or_file=$1 "/" $element
? ? ? ? If [-D $dir _or_file]
? ? ? ? Then?
? ? ? ? ? ? Jieya $dir _or_file
? ? ? ? Else
? ? ? ? ? ? if ["${dir_or_file##*.}" = "tgz"]; Then
TAR-ZXVF $dir _or_file-c $todir?
? ? ? ? ? ? Fi?
Fi??
? ? Done
? ? echo "tar success"??
}
function Taltoltime () {
Cat $ | While Read Myline
Do
? ? ? ? var=$ (cat $myline | grep "Time")
? ? ? ? if [[$var! = ""]]; Then
var=${var//"Time:"/|}
? ? ? ? ? ? ? ? Array= (${var//|/})
? ? ? ? ? ? ? ? For var2 in ${array[@]}
? ? ? ? ? ? ? ? Do
? ? ? ? ? ? ? ? ? ? ? ? Arraylr= (${var2//,/})
voicetime=$ (($voicetime +$ ((${arraylr[1]}-${arraylr[0)})))
? ? ? ? ? ? ? ? ? ? ? ? echo $voicetime??>
? ? ? ? ? ? ? ? Done
? ? ? ? Fi
Done
}
function Iterate () {

? ? for element in $outdir/????
? ? Do
CD $outdir
echo 0;? ${element##
/}.txt
For onetxt in $element/
Do
voicetime=$ (cat ${element##
/}.txt)
Taltoltime $onetxt $voicetime ${element##*/}.txt
Done
? ? Done
? ? echo "Success"
}
Jieya $from
Iterate

Shell unzip the package to find the sum of all the text's recording duration

Related Article

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.