admin管理员组文章数量:1125616
I want to sync from source to dest, only pass those files with postfix "*.gz"
the tree command of tree root@tt:/source is
/source
├── 20250108
│ └── tt
│ ├── binance
│ │ └── swap
│ │ └── bookticker
│ │ ├── 1000000MOG_USDT.20250108.bin.gz
I tried:
rsync -avP -n -f "+ */*/*/*/*/*.gz" -f "- *" root@tt:/source /dest
rsync -avP -n -f "+ *.gz" -f "- *" root@tt:/source /dest
above two commands matchs none.
could you help on this? ps. i want to keep the directories tree structure, also.
I want to sync from source to dest, only pass those files with postfix "*.gz"
the tree command of tree root@tt:/source is
/source
├── 20250108
│ └── tt
│ ├── binance
│ │ └── swap
│ │ └── bookticker
│ │ ├── 1000000MOG_USDT.20250108.bin.gz
I tried:
rsync -avP -n -f "+ */*/*/*/*/*.gz" -f "- *" root@tt:/source /dest
rsync -avP -n -f "+ *.gz" -f "- *" root@tt:/source /dest
above two commands matchs none.
could you help on this? ps. i want to keep the directories tree structure, also.
Share Improve this question asked Jan 9 at 6:33 nothingismenothingisme 1215 bronze badges1 Answer
Reset to default 0To sync files with the .gz postfix from the source to the destination while preserving the directory structure, you can use the following rsync command:
rsync -avP --include='*/' --include='*.gz' --exclude='*' root@tt:/source/ /dest
--include='*/'
includes all directories, --include='*.gz'
includes all .gz
files, and --exclude='*'
excludes all other files.
This command ensures that only .gz files are transferred, and the directory structure is preserved.
版权声明:本文标题:linux - How to select all files with certain postfix in all subdirectories in certain directory? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736668564a1946794.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论