tcsh scripting, problems with find and special characters in file names or directory names

流过昼夜 提交于 2019-12-23 05:26:11

问题


Im a beginner scripter, writing scripts in tcsh and csh(these are teached in my course)

Im writing a script which uses find for putting path of directories this is the part of the script:

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

it works fine until the file or directory names arent named such as: @fi@@lename&& or −filename or :−,?!drectoryanem!-``

These special characters i couldnt handle i changed the find script to:

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

bit none of these works, when i want to use the path from the list in this next script:

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

it couldnt handle these special file names, so i get many errors like find: −."!filename: no such filename or directory


回答1:


I worked it out

It had to be this way:

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

now it ignores everything in the filenames

and in:

foreach j ($subor:q)

i quoted it this way it ignores the white characters in file names



来源:https://stackoverflow.com/questions/19589187/tcsh-scripting-problems-with-find-and-special-characters-in-file-names-or-direc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!