使用多个while循环和读取行的bash脚本

时间:2013-07-07 10:23:52

标签: bash while-loop flac

我正在尝试编写一个bash脚本来创建一些音乐播放列表。我卡住的部分是读取线的while循环。我想我已经在考虑这个了,所以我转向stackoverflow寻求帮助。

# The first while loop is how many playlists I want to create
i=1
while [ $i -le $plist ]
do
    echo -e "iteration $i"
    i=$[$i + 1]

    z=0
    # This while loop is for the length of time I want the playlist to be
    while [ $z -le $TOTAL ]
    do
       echo -e "Count $z"
       z=$[$z + xxx]
       # This while loop is for reading the track list previously generated.
       # It would read the line, calculate the track length, 
       # add to $z, cp the track to a folder
       while read line
       do
            secs=$(metaflac --show-total-samples --show-sample-rate "$line" | tr '\n' ' '
            | awk '{print $1/$2}' -)
            z=$[$z + $secs]
            cp $line to destination folder 
       done
    done
done

0 个答案:

没有答案