![특정 이름 패턴을 찾을 때 다른 형식의 파일 나열](https://linux55.com/image/47111/%ED%8A%B9%EC%A0%95%20%EC%9D%B4%EB%A6%84%20%ED%8C%A8%ED%84%B4%EC%9D%84%20%EC%B0%BE%EC%9D%84%20%EB%95%8C%20%EB%8B%A4%EB%A5%B8%20%ED%98%95%EC%8B%9D%EC%9D%98%20%ED%8C%8C%EC%9D%BC%20%EB%82%98%EC%97%B4.png)
txt 파일을 편집하고 싶습니다 videoA
. videoB
movs 파일 이름에 네임스페이스가 포함된 경우에만 -test
예를 들어.
videoDir
|-videoA
|- videoA_v001_test.mov
|- videoA_v001_info.txt
|-videoB
|- videoB_v001_test.mov
|- videoB_v001_info.txt
|-videoC
|- videoC_v002.mov
|- videoC_v002_info.txt
위에서 수정 하고 싶었 videoDir/videoA/videoA_v001_info.txt
으나 해당 파일명에 .videoDir/videoB/videoB_v001_info.txt
videoC_v002_info.txt
.mov
test
find -name "*.mov" | grep -rn "test" | find -name "*.txt"
출력에서 txt 파일로 필터링할 것이라고 생각했기 때문에 - , find -name "*.txt"` 명령을 생각해 냈지만 find -name "*.mov" | grep -rn "test" does indeed lists out the 2 files that fulfills the condition (videoA and videoB). I added in
여전히 모든 txt 파일을 나열했기 때문에 틀렸습니다.
답변1
그리고 zsh
:
vi ./**/*_test.mov(.s:_test.mov:_info.txt:)
답변2
당신은 다음과 같은 것이 필요합니다
find . -name "*.mov" -exec grep test {} + | sed -n 's/^\([^:]*\):.*$/\1/p' | xargs -d \\n -n 1 $EDITOR
한 번에 하나의 파일을 여는 데 사용됩니다.
또는
find . -name "*.mov" -exec grep test {} + | sed -n 's/^\([^:]*\):.*$/\1/p' | xargs -d \\n $EDITOR
동시에 열어보세요
(파일 이름에 콜론이 포함되어 있지 않다고 가정)