ls -a /var/www/html/wp
. .. .git
index.php wp-blog-header.php wp-cron.php wp-mail.php
license.txt wp-comments-post.php wp-includes wp-settings.php
readme.html wp-config.php wp-links-opml.php wp-signup.php
wp-activate.php wp-config-sample.php wp-load.php wp-trackback.php
wp-admin wp-content wp-login.php xmlrpc.php
我想将/var/www/html/wp目录下面除去.git外,说有的文件递归复制到 /tmp/test
ls -a /var/www/html/wp|grep -v '.git'
可以删除.git文件
这个命令可以复制
ls /var/www/html/wp |grep -v '.git' |xargs -i cp -r {} /tmp/test/{}
但是,复制完成后,文件结构全部变了。
debian8@hwy:/var/www/html/wp$ ls /tmp/test
about.php load-styles.php revision.php
admin-ajax.php maint setup-config.php
admin-footer.php media-new.php term.php
admin-functions.php media.php theme-editor.php
admin-header.php media-upload.php theme-install.php
admin.php menu-header.php themes.php
admin-post.php menu.php tools.php
async-upload.php moderation.php update-core.php
comment.php ms-admin.php update.php
credits.php ms-delete-site.php upgrade-functions.php
css ms-edit.php upgrade.php
custom-background.php ms-options.php upload.php
custom-header.php ms-sites.php user
customize.php ms-themes.php user-edit.php
edit-comments.php ms-upgrade-network.php user-new.php
edit-form-advanced.php ms-users.php users.php
edit-form-comment.php my-sites.php widgets.php
edit-link-form.php nav-menus.php wp-activate.php
edit.php network wp-admin
edit-tag-form.php network.php wp-blog-header.php
edit-tags.php options-discussion.php wp-comments-post.php
export.php options-general.php wp-config.php
freedoms.php options-head.php wp-config-sample.php
images options-media.php wp-content
import.php options-permalink.php wp-cron.php
includes options.php wp-includes
index.php options-reading.php wp-links-opml.php
install-helper.php options-writing.php wp-load.php
install.php plugin-editor.php wp-login.php
js plugin-install.php wp-mail.php
license.txt plugins.php wp-settings.php
link-add.php post-new.php wp-signup.php
link-manager.php post.php wp-trackback.php
link-parse-opml.php press-this.php xmlrpc.php
link.php profile.php
load-scripts.php readme.html
debian8@hwy:/var/www/html/wp$ ls /var/www/html/wp
index.php wp-blog-header.php wp-cron.php wp-mail.php
license.txt wp-comments-post.php wp-includes wp-settings.php
readme.html wp-config.php wp-links-opml.php wp-signup.php
wp-activate.php wp-config-sample.php wp-load.php wp-trackback.php
wp-admin wp-content wp-login.php xmlrpc.php
我不想这样做
cp -r /var/www/html/wp/ /tmp/test
rm /tmp/test/.git
rsync 不错,tar 也是可以的(并且更简单,不用考虑使用哪些选项):
如果你用 zsh,可以