Use of find in unix on strange file/directory names

I’m 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 aren’t named such as:

[email protected]@lename&& or −filename or :−,?!drectoryanem!-

These special characters I couldn’t handle, I changed the find script to:

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

but 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`)

it couldn’t handle these special file names, so I get many errors like find:

−."!filenda no such filename or directory


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

Leave a Reply

Your email address will not be published. Required fields are marked *