用grep命令查找文件中带特定扩展名的字符串

如在日志中查找对js文件的请求,能够这么写shell

grep -Po '\w+\.js' access.log

若是要进一步排除一些文件名,能够这么写less

grep -Po '\w+\.js' access.log | grep -v 'index.js\|search.js' | less

若是要作成一个可传入参数的shell脚本的话,能够这么写日志

grep -Po '\w+\.js' $1 | grep -v 'index.js\|search.js' | less
相关文章
相关标签/搜索