23,118
社区成员
发帖
与我相关
我的任务
分享
grep -ERh '\d{7}' path/to/dir/ > path/to/outfile
#!/bin/bash
#auth cy
for files in `ls /tmp/tel`
do
file=`echo $files| awk -F / '{print}'`
num=`grep "[0-9]\{11\}" $file`
echo "$num" >> tel.txt
done
不晓得具体的应用,简单地码两行,试着用用find . -type f|xargs grep -h '[1234567890]'>/tmp/result.txt
输出所有数字到result.txtgrep -ERh '\d{7}‘ path/to/dir/ > path/to/outfile
grep -ERh '\d{7} path/to/dir/ > path/to/outfile
grep -ERh '\d{7} path/to/dir/ path/to/outfile
这里匹配的是 7 个数字以上,如果需要对电话号码做更精准的限制,比如手机号,可以换成 ‘1\d{10}'。