在 Linux 下,你可以使用 grep 命令的 -i
选项来忽略大小写进行过滤
grep -i "example" file.txt
这将在 file.txt
文件中搜索包含 “example”(不区分大小写)的行。如果你想从标准输入中搜索,可以使用管道:
echo "This is an Example." | grep -i "example"
这将输出 “This is an Example.”,因为它包含了 “example”(不区分大小写)。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:linux grep如何忽略大小写搜索