csh设置:无匹配错误通配符 [英] csh set: no match error wildcard

查看:406
本文介绍了csh设置:无匹配错误通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用通配符*查找目录中的文件,并将名称放入数组

trying to look up files in directories with wildcard *, and put the names into an array

文件具有相似的名称(MATCHr1,MATCHr2 ...)

the files have similar names (MATCHr1, MATCHr2 ... )

当文件不存在时可能会出现问题(有可能)

the problem arises when the file does not exist (which is a possibility)

set命令返回 no匹配错误并终止循环

set command returns a "no match" error and terminates the loop

如果发生这种情况,我如何通过跳转到下一个迭代来处理错误?

if this happens how can i get it handle the error by jumping to the next iteration?

set SUBIDS = (10003 10005 10006)

foreach SUBID ($SUBIDS)

foreach SEQR ( MATCH ENC NBACK SIMON FACE )

ls -l  *${SEQR}*.nii.gz

set Array = *${SEQR}*.nii.gz

echo $Array[*]

....其余代码可使用以下内容创建文本文件
的数组,当 * $ {SEQR} *。nii.gz 返回文件名

....rest of code works to use contents of Array to create text files and works great when the *${SEQR}*.nii.gz returns a file name

,但在不使用通配符进行匹配时失败

but fails when the no matches are made with the wildcard

任何帮助都将得到很好的补偿

Any help would be well apreciated

谢谢!

推荐答案

您可以这样做并检查$ status (或$ STATUS,取决于您的系统)标志:

ls -l * $ {SEQR} *。nii.gz> / dev / null;如果!$ status然后...

you can do you ls and check the $status (or $STATUS, depends on your system) flag:
ls -l *${SEQR}*.nii.gz >> /dev/null ; if !$status then ...

这篇关于csh设置:无匹配错误通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆