• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 432
  • Last Modified:

How do I declare c shell variables with a list of directory paths and use them in foreach

How do I declare c shell variables with a list of directory paths ?

I tried the following but I dont think its correct.

set DestDir[1] = /home/milligram/MyVideos/In
set DestDir[2] = /home/milligram/MyVideos/Is
set DestDir[3] = /home/milligram/MyVideos/IT
set DestDir[4] = /home/milligram/MyVideos/Ho
set DestDir[5] = /home/milligram/MyVideos/FM)
#set DestDir = (/home/milligram/MyVideos/In /home/milligram/MyVideos/Is /home/milligram/MyVideos/Ho /home/milligram/MyVideos/FM /home/milligram/MyVideos/IT)


how do I execute foreach loops with the paths?

Is this corret?

foreach dest ($DestDir)

echo $dest

end
0
wademi
Asked:
wademi
1 Solution
 
farzanjCommented:
Yes, it is correct.

set DestDir = (/home/milligram/MyVideos/In /home/milligram/MyVideos/Is /home/milligram/MyVideos/Ho /home/milligram/MyVideos/FM /home/milligram/MyVideos/IT)


foreach dest ($DestDir)

echo $dest

end
0
 
omarfaridCommented:
if you are interested in creating / setting arrays then look at links below

http://www-cs.canisius.edu/ONLINESTUFF/UNIX/shellprogramming.html#M
http://www.grymoire.com/Unix/Csh.html#uh-22
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now