Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试编写一个脚本来计算系统中所有名称为奇数字符的文件,只有名称而不是扩展名。有人可以帮助我吗?我已经这样做了,但它不起作用
find /usr/lib -type f | cut -f 1 -d '.' | rev | cut -f 4 -d '/' | rev | wc -m
用这个我计算所有文件的所有字符,但是我如何计算一个文件的字符数?
以下awk命令将打印出名称中包含奇数个字符的文件数。
awk
find /usr/lib -type f | awk -F/ '{gsub(/\.[^\.]*$/,"",$NF);if(length($NF)%2!=0)i++}END{print i}'
打印所有奇数个字符的文件名,
find /usr/lib -type f | xargs -i basename {} | cut -d . -f 1 | grep -Pv '^(..)+$'
管wc数。
wc