nnn*_*nnn 24 shell directory rsync recursive
我想要rsync
递归文件夹,但希望子文件夹仅包含到一定深度。
例如,我想要 1、2、3 或 4 个这样的子文件夹的深度:
source/
??? subfolder 1
? ??? subsubfolder
? ? ??? subsubsubfolder
? ? ? ??? wanted with depth 4.txt
? ? ??? wanted with depth 3.txt
? ??? wanted with depth 2.txt
??? subfolder 2
? ??? wanted with depth 2.txt
??? wanted with depth 1.txt
Run Code Online (Sandbox Code Playgroud)
nnn*_*nnn 38
方便--exclude=
选择。
同步到深度为 2(文件夹和子文件夹中的文件):
rsync -r --exclude="/*/*/" source/ target/
Run Code Online (Sandbox Code Playgroud)
它会给你这个:
target/
??? subfolder 1
? ??? wanted with depth 2.txt
??? subfolder 2
? ??? wanted with depth 2.txt
??? wanted with depth 1.txt
Run Code Online (Sandbox Code Playgroud)
同步到深度 3(文件夹、子文件夹和子文件夹中的文件):
rsync -r --exclude="/*/*/*/" source/ target/
Run Code Online (Sandbox Code Playgroud)
会给你:
target/
??? subfolder 1
? ??? subsubfolder
? ? ??? wanted with depth 3.txt
? ??? wanted with depth 2.txt
??? subfolder 2
? ??? wanted with depth 2.txt
??? wanted with depth 1.txt
Run Code Online (Sandbox Code Playgroud)