UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 29th, 2004, 03:00 AM
huckleberry huckleberry is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 26 huckleberry User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old July 29th, 2004, 03:25 AM
stevengs stevengs is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Germany
Posts: 394 stevengs User rank is Lance Corporal (50 - 100 Reputation Level)stevengs User rank is Lance Corporal (50 - 100 Reputation Level)stevengs User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 Days 4 h 36 m 24 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0
hey Huck,

filelist='ls ${sourcedir}'

or better

filelist='ls $sourcedir'

-Steven

Reply With Quote
  #3  
Old July 29th, 2004, 03:44 AM
huckleberry huckleberry is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 26 huckleberry User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old July 29th, 2004, 12:05 PM
Perderabo Perderabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 121 Perderabo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 54 sec
Reputation Power: 5
eval dir=\$$sourcedir
ls $dir

Reply With Quote
  #5  
Old July 29th, 2004, 03:03 PM
stevengs stevengs is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Germany
Posts: 394 stevengs User rank is Lance Corporal (50 - 100 Reputation Level)stevengs User rank is Lance Corporal (50 - 100 Reputation Level)stevengs User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 Days 4 h 36 m 24 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0
right, sorry, misunderstood the question...

-Steven

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > KSH variable substitution


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway