1

要做到这一点

#!/bin/bash
find ./ -name '*.mp3' | while read -r i; do
echo "----------------------------------------"
         if [ $(mp3info -x "$i" | grep Audio | awk '{print $2}') < 130 ]
         then
                read -p "Delete?  " -n 1 -r
                        if [[ $REPLY =~ ^[Yy]$ ]]
                        then
                        rm -f "$i" && echo "$i succesfully deleted!"
                        fi
        fi
echo "----------------------------------------"
done

它以这个输出停止:

Error opening MP3: /Like A Prayer/Madonna - Act Of Contrition.mp3: No such file or directory

看起来文件路径有错误,导致缺少前导点。

4

1 回答 1

0

我认为 IFS 设置为带有“。”的值。此外,要比较整数,请使用 [[ ]]:

#!/bin/bash

find ./ -name '*.mp3' | while IFS='' read -r i; do
    echo "----------------------------------------"
    if [[ $(mp3info -x "$i" | grep Audio | awk '{print $2}') -lt 130 ]]; then
        read -p "Delete?  " -n 1 -r
        if [[ $REPLY =~ ^[Yy]$ ]]; then
            rm -f "$i" && echo "$i succesfully deleted!"
        fi
    fi
    echo "----------------------------------------"
done

顺便说一句,我认为您必须将文件添加到问题中:

        read -p "Delete $i? " -n 1 -r
于 2013-08-07T09:36:08.080 回答