我创建了一个小型bash脚本,可以在iOS项目中找到未使用的图像(* .jpg和* .png)。这是相同的代码。
//For removing space and replace '\n' in file and folder names
`IFS=$'\n'`
//Find all files with extension *.png and *.jpg
`for i in `find . -name "*.png" -o -name "*.jpg"``; do`
//Get the base name of found file
file=``basename -s .jpg "$i" | xargs basename -s .png``
//Replace "\n" with original space so that ack can search exact file name in all files
filenameWithSpace="${file//$'\n'/ }"
//Merge both basename and extension for ack command
//Add this "</dev/null" to ack command for it to work on jenkins setup
`extension="${i##*.}"`
`filename="$filenameWithSpace.$extension"`
result=`ack -i --ignore-file=match:/.\.pbxproj/ "$filename" </dev/null`
//result=ack -i "$filename" </dev/null
//If result is NULL then ack did not find any occurrence of the filename in any file
`if [ -z "$result" ];`
`then `
`echo "$i" `
`fi `
`done`
我的搜索中是否应包含“.pbxproj”?我问这个问题,因为包含和排除“.pbxproj”会给我带来不同的结果。
提前致谢。