我的脚本正在阅读和显示id3标签.如果该字段为空,但是我尝试的每个if语句都不会工作,我试图让它回显未知. id3标签是一个固定的大小,所以它们永远不会为空,但如果没有值,它们将被填充空格.标题标签长度为30个字符.到目前为止我已经尝试过了
echo:$string:#outputs 2 ::
如果[-z“$string”]#因为空格将始终评估为true
x = echo $string | tr -d“如果[-z“$string”];
#still评估为true但回声:$x:it echos ::
剧本
#!bin/bash
echo "$# files";
while [ "$i" != "" ];
do
TAG=`tail -c 128 "$i" | head -c 3`;
if [ $TAG="TAG" ]
then
ID3[0]=`tail -c 125 "$1" | head -c 30`;
ID3[1]=`tail -c 95 "$1" | head -c 30`;
ID3[2]=`tail -c 65 "$1" | head -c 30`;
ID3[3]=`tail -c 35 "$1" | head 4`;
ID3[4]=`tail -c 31 "$i" | head -c 28`;
for i in "${ID3[@]}"
do
if [ "$(echo $i)" ] #the if statement mentioned
then
echo "N/A";
else
echo ":$i:";
fi
done
else
echo "$i does not have a proper id3 tag";
fi
shift;
done