반복하고 싶다
touch ../template/filename
어디에서 filename
오는가 find
. 내가 원하는 xargs
적용하는 touch
작업을,하지만 난 그나마 그것을 할 공백을 삽입 그것은 일반적으로 파생하는하는 것처럼 :
touch ../template/ filename
불완전한 명령은 다음과 같습니다. 어떻게 완성합니까?
find *.html | xargs touch ../template/WHAT-NOW
답변
find -name "*.html" | xargs -d"\n" -I"{}" touch ../template/{}
find -name "*.html" -exec touch ../template/{} \;
그 주 find *.html
와일드 카드 확장되기 때문에, 잘못 전에 명령 실행.
답변
쉘 루프로 작성하기가 더 쉽습니다. 예를 들어, C 쉘에서 다음을 작성할 수 있습니다.
foreach i (`find -name "*.html"`)
touch ../template/$i
end
그리고 여기 bash에 있습니다.
for i in `find -name "*.html"`
do
touch ../template/$i
done
그리고 Hamilton C 쉘 (전체 공개 : 저자 임)에서 트리 워크에 “…”와일드 카드 를 추가하여 다음 과 같이 작성할 수 있습니다.
foreach i (.../*.html)
touch ../template/$i
end
답변
대신 GNU Parallel을 사용하십시오. 이렇게하면 파일 이름에 공백 ‘또는 “이 포함되어 있으면 놀라움을 피할 수 있습니다.
find *.html | parallel -X touch ../template/{/}
자세한 내용은 소개 동영상을 참조하십시오. https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1