Hi all,
I have a file looks something like this:
aaaa
bbbbbb
ccc
dddddddd
I will like a script that can
echo line1
export line1 as env variable
echo line2
export line2 as env variable
etc
etc
Thanks in advance
Hi all,
I have a file looks something like this:
aaaa
bbbbbb
ccc
dddddddd
I will like a script that can
echo line1
export line1 as env variable
echo line2
export line2 as env variable
etc
etc
Thanks in advance
for ELE in `grep -v "^~" infile`; do
echo "${ELE}"
export "${ELE}"
done
Of course you should think about assigning variable names in your file.
Hi Zaxxon,
Thanks for the fast response...
It will be fine if I can set it as a variable in a file, but what I'm after is the following:
Say I have a text file named file.text that has the following entries:
aaaa
bbb
cc
d
What I want to do is to list them as a menu in format:
1) aaaa
2) bbb
3) cc
4) d
and at the same time set them as variables
sid1 = aaaa
sid2 = bbb
etc
etc
Can you please help with this, I have the following but it doesn't work like I want it to.
num = 'cat file.txt | wc -l'
for ELE in `grep -v "^~" file.txt`
do
for (( i = 0; i < num; i++))
do
echo "$i) ${ELE}"
sid $i="${ELE}"
done
done
The output from this gives:
1) aaaa
1) bbb
and doesn't set the variables correctly either.
Thanks in advance
If your shell has select then perhaps this is sufficient.
select ELE in `cat file.txt`; do
echo $ELE
done
(Type ctrl-D to escape from the prompt.)