Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Linux ターミナルで作業していますが、特定のディレクトリで c ファイルを検索する方法を知りたいです。現在のディレクトリでは機能していますが、ディレクトリ usr/ ではどうすればよいですか
私がした現在のディレクトリのために
grep -l "main" *.c
最初にディレクトリを変更せずに /usr ディレクトリを検索する方法を知りたいです。ありがとう。
検索したいファイルパターンに必要なディレクトリ名をプレフィックスとして付けることができるはずです。
grep -l "main" /usr/*.c
以下を使用することもできます。
find /usr/ -name "*.c"
それが /usr/ ディレクトリ内の C ファイルだけの場合は、後になります。