Reputation: 1655
The following piece of code is printing /home/user/dir/*@(${host}|${hostname})* instead of printing each of the files in the directory.
#!/usr/bin/ksh
host=foo
hostname=bar
config_path="/home/user/dir"
search=$config_path/*_@(${host}|${hostname})_*
for file in $search
do
echo $file
done
And It works if I do like this
#!/usr/bin/ksh
host=foo
hostname=bar
config_path="/home/user/dir"
#search=$config_path/*_@(${host}|${hostname})_*
for file in $config_path/*_@(${host}|${hostname})_*
do
echo $file
done
I've three questions.
1) Why its returning the string when pattern is assigned to variable?
2) I'm using this pattern in so many places, so it's better to assign it a variable. How to fix this?
3) Is it fixed in the newer version of ksh?
I'm using SunOS server 5.10 Generic_147441-23 i86pc i386 i86pc and got ksh version by typing the following command.
$ set -o vi
$ Version M-11/16/88i
Upvotes: 1
Views: 440