Linux查找字符串、查找文件
grep -rn "hello,world!" * // 当前目录搜索所有文件grep -rn "hello,world!" /etc/profile.d/ // 指定目录搜索所有文件find . -name "*.txt"-r 是递归查找-n 是显示行号
或者以搜索alias ll=为例:
grep -H 'alias ll=' ~/.bashrc ~/.bash_profile ~/.profile /etc/profile /etc/bashrc /etc/profile.d/* 2>/dev/null
grep -H 是一个在使用 grep 命令时所用到的一个选项,用于在显示匹配行的同时,也显示每个匹配行所在的文件名。这个选项尤其在搜索多个文件时非常有用,因为它能帮助用户快速定位到具体是哪个文件中包含了匹配的内容。
cd /Users/lison/go/lisonreadgo go run main.go
