Linux中ntext=过傻逼茅台集团的系列的酒后里成酿我是咱们茅台集团厂家的区域经理福特尼这个整个河北省的也是感谢您这两门迁衣主播和茅台集nn首先nhomecikujstxt-homecikujytxt-homecikumrtxt-homecikudaikuantxt-homecikulicaitxt-homecikumrtxt-homecikutousutxt-homecikuyanzhongjinggaotxt-homecikuyidongzengzhitxt-homecikuyisizh
#!/bin/bash
定义变量,保存文件路径和关键词
files=( "/home/ciku/js.txt" "/home/ciku/jy.txt" "/home/ciku/mr.txt" "/home/ciku/daikuan.txt" "/home/ciku/licai.txt" "/home/ciku/mr.txt" "/home/ciku/tousu.txt" "/home/ciku/yanzhongjinggao.txt" "/home/ciku/yidongzengzhi.txt" "/home/ciku/yisizhapian.txt" ) keywords=("傻逼" "茅台")
定义函数,遍历所有文件,查找关键词并输出
function search_keyword { for file in "${files[@]}" do for keyword in "${keywords[@]}" do if grep -q "$keyword" "$file"; then echo -n "$keyword " fi done done }
执行函数
search_keyword
输出换行符,美化输出结果
echo ""
原文地址: https://www.cveoy.top/t/topic/p3V 著作权归作者所有。请勿转载和采集!