#!/bin/bash olddir=/home/img/luimg newdir=/home/img/luimg/thumb while read line do if [ -f $olddir${line%.*}.jpg ] then rm -f $olddir${line%.*}_375_0.jpg #ls $olddir${line%.*}_375_0.jpg #ls $newdir${line%.*}* rm -f $newdir${line%.*}* fi done < lu.txt
这里{line%.*}就是取到去掉{line}的后缀的值,然后来操作