Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Menu Problem 4

Status
Not open for further replies.

midge25

Programmer
Jul 19, 2002
9
Hi,

I am creating a menu system (with a number of sub menus) and come across a sticky problem.....

I think its best to explain with an example

e.g.

The following directory structure (the number of directories can vary) exists:

apple
banana
cat
dog
elephant
..

I need to create an option for each of the directories. These can vary in number and name.

I have outputted the directory names to a flat file:

> ls -1 > /tmp/directories.dat

1) I dont know how I can list these in the menu display

2) How do I create a case statement for an action against each option considering the number of dirs can vary and differ in name.

Thanks in advance.
 
for i in $(cat /tmp/directories.dat)
do
echo $i
done

???????
 
UUOC!
Code:
#!/bin/ksh

select what in $(< /tmp/directories.dat); do
  echo "you selected $what by typing $REPLY"
done

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Hi Vlad,

I've never seen that $(< filename) syntax before... can you explain how/why it works?

I know it works, but I can't understand why redirecting stdin to a null command echos the contents?

Annihilannic.
 
man_ksh said:
The command substitution $(cat file) can be replaced by the equivalent $(<file)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top