是否有一个命令可用于获取包含一行或多行nnn字符的php文件? (例如160)
开发人员编码检查。
感谢。
答案 0 :(得分:1)
我多年没写过bash脚本,这很有趣:D
#!/bin/bash
# search for php files in /var/www
files=($(find /var/www -type f -name "*.php"))
# loop file one by one
for file in "${files[@]}"
do
# read file line by line
while IFS='' read -r line || [[ -n "$line" ]]; do
# check is line longer than 160 chars
if [ ${#line} -ge 160 ]; then
# output path to file and break
echo "$file"
break
fi
done < "$file"
done