linux grep如何忽略大小寫(xiě)搜索

小樊
82
2024-08-30 21:24:02

在Linux中,使用grep命令時(shí),可以通過(guò)添加-i選項(xiàng)來(lái)實(shí)現(xiàn)忽略大小寫(xiě)的搜索

grep -i "search_pattern" file_name

這里的search_pattern是你要搜索的文本,file_name是你要在其中進(jìn)行搜索的文件名。例如,如果你想在名為example.txt的文件中搜索hello,不區(qū)分大小寫(xiě),你可以使用以下命令:

grep -i "hello" example.txt

這將返回包含hello、Hello、HELLO等所有大小寫(xiě)組合的行。

0