正则获取指定目录信息
sudo df -Th | grep -o "/media/pi/.*" | sed "s/\/media\/pi\///g"
清除无效挂载的历史遗留目录
for file in `ls /media/pi/ | tr " " "\?"`
do
file=`tr "\?" " " <<<$file`
file_path=/media/pi"/"$file
if [ -d "$file_path" ];then
dst_path=""
for mfile in `df -Th | grep -o "/media/pi/.*"`
do
if [ "$file_path" == "$mfile" ];then
echo "$file_path"
dst_path=$file_path
fi
done
if [ -z "$dst_path" ];then
if [ -n "$file_path" ];then
echo "rm $file_path"
rm -rf "$file_path"
fi
fi
fi
done