将没有文件的目录从 /etc 复制到其他目录

将没有文件的目录从 /etc 复制到其他目录

我想将所有不包含文件的 /etc 目录复制到其他目录。还有一个条件,即它们必须从第一级开始以 a、b 或 c 开头。

我尝试过这个:

user@system:/etc$ find . -maxdepth 1 -name "[abc]*" -type d -exec cp {} $HOME/bases2/p01 \;

cp: -r not specified; omitting directory './alternatives'
cp: -r not specified; omitting directory './ca-certificates'
cp: -r not specified; omitting directory './binfmt.d'
cp: -r not specified; omitting directory './apt'
cp: -r not specified; omitting directory './cron.monthly'
cp: -r not specified; omitting directory './chatscripts' 
cp: -r not specified; omitting directory './apm'
cp: -r not specified; omitting directory './cups'
cp: -r not specified; omitting directory './cron.d'
cp: -r not specified; omitting directory './apport'
cp: -r not specified; omitting directory './alsa'
cp: -r not specified; omitting directory './cracklib'
cp: -r not specified; omitting directory './cron.hourly'
cp: -r not specified; omitting directory './cron.daily'
cp: -r not specified; omitting directory './acpi'
cp: -r not specified; omitting directory './cron.weekly'
cp: -r not specified; omitting directory './cupshelpers'
cp: -r not specified; omitting directory './brltty'
cp: -r not specified; omitting directory './avahi'
cp: -r not specified; omitting directory './console-setup'
cp: -r not specified; omitting directory './bluetooth'
cp: -r not specified; omitting directory './bash_completion.d'
cp: -r not specified; omitting directory './chromium.d'
cp: -r not specified; omitting directory './apparmor.d'
cp: -r not specified; omitting directory './apparmor'
cp: -r not specified; omitting directory './calendar'

“未指定 -r”是什么意思?哪种方法才是正确的?

我是新来的,正在学习 Linux。

答案1

该命令给出错误“未指定 -r” cp。您将其指向包含子目录的目录(“-r”代表“递归”),除非您使用该开关明确告诉它这样做,否则它不会复制这些目录。

要查找空目录,请使用:

find . –type d -empty

相关内容