Results 1 to 1 of 1
Hi,
I try to run the following script :
#!/bin/tcsh -f
set sourceDir = "$argv[1]"
echo ${sourceDir}
set listOfPictures_1 = `ls "${sourceDir}"/*.jpg`
echo $listOfPictures_1
set listOfPictures_2 = `find "${sourceDir}" -name ...
- 01-07-2009 #1Just Joined!
- Join Date
- Oct 2006
- Posts
- 29
White space issue in a tcsh variable in a foreach loop
Hi,
I try to run the following script :
#!/bin/tcsh -f
set sourceDir = "$argv[1]"
echo ${sourceDir}
set listOfPictures_1 = `ls "${sourceDir}"/*.jpg`
echo $listOfPictures_1
set listOfPictures_2 = `find "${sourceDir}" -name '*.jpg'`
echo $listOfPictures_2
#set listOfPictures_3 = ("${sourceDir}"/*.jpg/)
#echo $listOfPictures_3
echo ''
foreach file ($listOfPictures_1)
echo $file
end
exit 0
I run :
./essai.csh pictures\ with\ snow (there is a white space after each \).
I get the following :
pictures with snow
pictures with snow/SnowInMarseille.jpg
pictures with snow/SnowInMarseille.jpg
pictures
with
snow/SnowInMarseille.jpg
If I add the 2 commented lines, I get :
set: No match.
I would like to get in the foreach loop :
pictures with snow/SnowInMarseille.jpg
I had a look at these 2 threads (http://www.linuxforums.org/forum/lin...ng-spaces.html and http://www.linuxforums.org/forum/lin...ace-issue.html) but I did not succeed to do what I want (the IFS variable seems not to work in tcsh).
Is there a way for the foreach loop not to take into account white spaces ?
Should I write my script back in bash ?
Regards.
Xuo.


Reply With Quote