|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
KSH variable substitution
Hi,
I am trying to substitute a variable with another variable like below: for x in 1 2 3 4 do sourcedir=datadir${x} echo $sourcedir filelist=`ls ${${sourcedir}}` echo $filelist sleep 60 But this doesnt work. $sourcedir = datadir1 which is correct. datadir1 is a var pointing to a directory but filelist=`ls ${${sourcedir}}` doesnt work I want to ls the var $datadir1 but how do I do this given the way datadir1 ic constructed ?? Thanks in advance |
|
#2
|
|||
|
|||
|
hey Huck,
filelist='ls ${sourcedir}' or better filelist='ls $sourcedir' -Steven |
|
#3
|
|||
|
|||
|
Hi Steven,
thanks for your help but that just tries to list datadir1 (e.g. ls datadir1). What I want it to do is ls $datadir1 which is a var defined and which points to a dir (e.g. /tmp/huck/). Any ideas? Cheers |
|
#4
|
|||
|
|||
|
eval dir=\$$sourcedir
ls $dir |
|
#5
|
|||
|
|||
|
right, sorry, misunderstood the question...
-Steven |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > KSH variable substitution |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|