1
在Bash中,我使用数组来存储我想通过正则表达式复制的文件。就像这样:使用正则表达式筛选文件
regex_2=(*.awk *.sh *utf8.txt *new.txt)
cp "${regex_2[@]}" $root_dest_dir_2
但是从扩展名的文件.SH我要排除那些像这样的结局:
*2016025a.sh *2015039.sh *20150810b.sh
所以排除那些.SH一个字母和多个号码之前结束或以.sh结尾,前面有多个数字。
该目录包含文件像这样:
dev_execute_fromFTP5.sh --> to copy
dev_execute_fromFTP5_2016025a.sh -- to exclude
extrac.sh --> to copy
execute_fromFTP5NT.sh --> to copy
execute_fromFTP5NT_20150226.sh --> to exclude
test5.sh --> to copy
.....
使用发现来代替。你想要复制的文件与不复制的文件又有什么不同? – 123
数组初始化中未引用的glob模式将预先扩展模式。 – anubhava
@anubhava你能举个例子吗?我不太了解未引用的glob模式。 – Firefly