![모든 하위 디렉터리에서 exampleDir이라는 이름의 모든 파일을 찾습니다.](https://linux55.com/image/113749/%EB%AA%A8%EB%93%A0%20%ED%95%98%EC%9C%84%20%EB%94%94%EB%A0%89%ED%84%B0%EB%A6%AC%EC%97%90%EC%84%9C%20exampleDir%EC%9D%B4%EB%9D%BC%EB%8A%94%20%EC%9D%B4%EB%A6%84%EC%9D%98%20%EB%AA%A8%EB%93%A0%20%ED%8C%8C%EC%9D%BC%EC%9D%84%20%EC%B0%BE%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
모든 하위 디렉터리에서 이름이 있는 모든 파일을 찾고 싶습니다.ExampleDir
예를 들어.
+ ParentDirA
+ ChildDirA
- file1.txt
+ ExampleDir
- file2.txt
+ ParentDirB
+ ChildDirB
- file3.csv
+ ExampleDir
- file4.csv
명령을 실행하면 file2.txt 및 file4.csv가 반환되어야 합니다.
나는 다음을 시도했습니다 :
find . -type d -name "ExampleDir" | xargs find -type f
find . -type d -name "ExampleDir" -exec find -type f {} \;
find . -type d -name "ExampleDir" -exec find -type f {} +
그들은 모두 다음을 반환합니다:
find: paths must precede expression
이 경로(내 생각에는 논리적이라고 생각함)로 가려면 find 명령에 경로를 전달하는 방법을 알아내야 합니다.
더 좋은 방법이 있나요?
답변1
단순화를 고려해보세요GNU에 의해 발견됨-path
확장하다:
find . -type f -path "*/ExampleDir/*"
답변2
나는 다음에서 답을 찾았습니다. xargs를 첫 번째 인수로 전달하도록 설정
find . -type d -name "ExampleDir" | xargs -I {} find {} -type f