我尝试grep -o 'aaa\\w*' * >>out
来过滤所有文件中以aaa...
开头的所有字符串:1.txt,2.txt,3.txt ...到out,结果是1.txt:aaa123 2.txt:aaa222 3.txt:aaaeee ...
但我只想: aaa123 aaa222 aaaeee ...
如何实现我的目标,谢谢您的帮助。
在多个文件上使用grep时,使用-h避免打印文件名
then just do
awk -F'[:]' '{print $2}' file.txt
considering file.txt to contain your grep result.
file.txt :
1.txt:aaa123
2.txt:aaa222
3.txt:aaaeee
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.