find . -type f -iname "*.xMl"| xargs grep -c mysql | grep -v ":0$" | sort -t : -k 2 -nr
find . -type f -regex ".+xml" -exec grep -l mysql {} \; | xargs grep -c mysql | sort -t : -k 2 -nr
2. 统计第二列重复出现次数最多的5个字符串
awk -F " # " '{print $2}' source.txt | sort | uniq -c | sort -nf | tail -n 5 > ~/PwdTop5.txt
awk '{print $3}' source.txt | sort | uniq -c | sort -nr | head -5 > ./PwdTop5.txt &
3. 统计邮箱类型出现频率最高的前5个
awk -F " # " '{print $3}' source.txt | cut -d @ -f 2 | sort | uniq -c | sort -nf | tail -n 5 > EmailTop5.txt
注:
source.txt 中的文本格式为
AAA # BBB # [email protected] AAB # BBC # [email protected] AAC # BBD # [email protected]
4. 将所有txt文件的第一行输出到first.txt文件中
find / -name "*.txt" -exec head -n 1 {} \; 1>first.txt 2>/dev/null &
5. 查找当前路径下最大的5个文件
find . -type f -exec ls -l {} \; | sort -nr -k 5 | head -n 5
6. 统计所有jpg文件的大小
find / -name "*.jpg" -exec wc -c {} \; | awk '{print $1}' | awk '{a+=$1} END{print a}'
7. 将PATH路径下所有非jpg和JPG文件内容中的aaa部分重命名为bbb部分
find $PATH -type f -print |grep -v ".*\.\(jpg\|JPG\)" | xargs sed -i "s/aaa/bbb/g"