除了条件之外,为什么要打破除外?

时间:2015-07-23 19:41:06

标签: bash debugging copy glob

我在Debian 8.1,GNU bash,版本4.3.30(1)-release(x86_64-pc-linux-gnu)和联想G50-30以及500 GB SSD和8 GB闪存中运行:

shopt -s extglob
cp -r !(Backups.backupdb/) /home/masi/Documents/

但它也会复制目录 Backups.backupdb / 中的所有内容,并在复制结束时确认。

复制过程中的消息

复制2小时后

cp: cannot stat ‘Backups.backupdb/masi\’s MacBook Air/2015-06-25-233115/Macintosh HD/System/Library/Image Capture/Automatic Tasks/MakePDF.app/Contents/Resources/ko.lproj/3x5로 자르기.mkpdf’: No such file or directory
cp: cannot stat ‘Backups.backupdb/masi\’s MacBook Air/2015-06-25-233115/Macintosh HD/System/Library/Image Capture/Automatic Tasks/MakePDF.app/Contents/Resources/ko.lproj/3x5에 맞추기.mkpdf’: No such file or directory
...
cp: cannot stat ‘Camera Uploads/2015-06-29 11.51.36.jpg’: Invalid argument
cp: cannot stat ‘Camera Uploads/2015-06-29 11.51.53.jpg’: Invalid argument
cp: cannot stat ‘Camera Uploads/Icon\r’: Invalid argument
cp: cannot stat ‘Cancer’: Invalid argument
cp: cannot stat ‘cardio bad/atria-en-ventrikels.swf’: Invalid argument
cp: cannot stat ‘cardio bad/extreme_90_180.swf’: Invalid argument
cp: cannot stat ‘Cardio databases tools’: Invalid argument
cp: cannot stat ‘Cardiology’: Invalid argument
...

我在意外浏览备份文件夹的地方。 这里的挑战是Backups.backupdb是几个TB并且看到它浏览它感觉不太好。

没有符号链接

我跑

ls -lR /media/masi/eb807ed8-7f45-35f8-a345-9da6692b228a/ |grep Backup

获得

ls: cannot access /media/masi/eb807ed8-7f45-35f8-a345-9da6692b228a/Cancer: Invalid argument
ls: cannot access /media/masi/eb807ed8-7f45-35f8-a345-9da6692b228a/Cardio databases tools: Invalid argument
ls: cannot access /media/masi/eb807ed8-7f45-35f8-a345-9da6692b228a/Cardiology: Invalid argument
drwxr-xr-x 1 root root          7 Jul  8 20:25 Backups.backupdb
ls: cannot open directory /media/masi/eb807ed8-7f45-35f8-a345-9da6692b228a/animations/Embryology/e17_files: Permission denied
^C

所以目录不是符号链接。 为什么extglob除了条件在这里通过浏览文件夹而被破坏?

1 个答案:

答案 0 :(得分:1)

尝试删除反斜杠(我为测试目的添加了echo):

shopt -s extglob
echo cp -r !(Backups.backupdb) /home/masi/Documents/

它适用于我的环境(GNU bash,版本4.3.30,OS X)