다음과 같은 파일 트리가 있습니다.
in
├── file1
├── dir1
└── dir2
├── dir3
│ ├──── file2
│ └──── junk1
├── junk2
└── junk3
in
다음과 같은 형제를 만들고 싶습니다.
out
├── file1
├── dir1
└── dir2
└─── dir3
└── file2
즉, in
를 out
제외하고 in/dir2
포함하여에 재귀 적으로 복사 합니다 in/dir2/dir3/file2
.
나는 다음을 시도했다.
rsync -a --exclude='in/dir2' --include='in/dir2/dir3/file2' in out
결과는 다음과 같습니다.
out
└── in
└── file1
그래서 나는 다음을 시도했다.
rsync -a --exclude='dir2' --include='dir2/dir3/file2' in/ out
결과 :
out
└── file1
원하는 rsync
유닉스 도구 나 다른 유닉스 도구를 어떻게 얻을 수 있습니까? 나는 배관 같은 이상한 방법을 사용하여 멀리하는 것을 선호 tar
로를 tar
…
답변
이것을 하나 이상의 rsync 명령으로 나누고 쉘 스크립트로 묶는 것은 어떻습니까?
또 다른 가능한 대안은 find와 cpio를 대상 장치에 결합한 것입니다.
답변
rsync를 사용 하여 --exclude-from=FILE
및 --include-from=FILE
옵션을 탐색 할 수 있습니다 .
--include-from=FILE
This option is related to the --include option, but it specifies a FILE that contains include patterns
(one per line). Blank lines in the file and lines starting with ’;’ or ’#’ are ignored. If FILE is -,
the list will be read from standard input.