我创建了一个小的 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”给我提供了不同的结果。
提前致谢。