【问题标题】:tcsh scripting, problems with find and special characters in file names or directory namestcsh 脚本,文件名或目录名中的查找和特殊字符问题
【发布时间】:2013-10-25 11:56:29
【问题描述】:

我是一名初学者,用 tcsh 和 csh 编写脚本(这些在我的课程中教授)

我正在编写一个脚本,它使用 find 来放置目录路径 这是脚本的一部分:

set list = (`find $PATH -type d`)

它可以正常工作,直到文件或目录名称未命名,例如: @fi@@lename&& 或 -filename 或 :-,?!drectoryanem!-``

这些我无法处理的特殊字符我将查找脚本更改为:

set list = ("`find $PATH -type d`")

当我想在下一个脚本中使用列表中的路径时,这些都不起作用:

foreach i ($list:q)
   foreach file (`find "$i" -maxdepth 1 -type f`)
   ....
   end
end

它无法处理这些特殊的文件名,所以我收到很多错误,比如 find: -."!filename: no such filename or directory

【问题讨论】:

  • 您能告诉我们csh 仍在任教的学校名称吗?只是为了让其他人可以避免它。

标签: tcsh


【解决方案1】:

我解决了

一定是这样的:

set subor = ("`find "'"$i"'" -type f -maxdepth 1`")

现在它会忽略文件名中的所有内容

进入:

foreach j ($subor:q)

我这样引用它会忽略文件名中的白色字符

【讨论】:

    猜你喜欢
    • 2014-05-12
    • 1970-01-01
    • 1970-01-01
    • 2013-05-17
    • 1970-01-01
    • 2015-11-08
    • 1970-01-01
    • 2021-04-20
    • 1970-01-01
    相关资源
    最近更新 更多