Thread View: comp.unix.shell
1 messages
1 total messages
Started by John R. Levine
Tue, 27 Nov 1990 04:39
Re: puzzle
Author: John R. Levine
Date: Tue, 27 Nov 1990 04:39
Date: Tue, 27 Nov 1990 04:39
24 lines
1143 bytes
1143 bytes
In article <1990Nov27.003659.3521@informix.com> you write:
>what I am trying to do: set a shell variable that
>contains the contents of another one that is referred
>to by concatenating two others. Sufficiently confusing?
No more confusing than any other Bourne shell string munging. The
trick is to build up the assignment string and then use eval to rescan it:
# Prints:
# Iteration is first_time
# Iteration is second_time
firsttime="first_time" secondtime="second_time"
PREFIX_WORDS="first second" SUFFIX="time"
for PREFIX in $PREFIX_WORDS
do
eval ITERATION=$\{$PREFIX$SUFFIX\}
echo "Iteration is $ITERATION"
done
Regards,
John Levine, johnl@iecc.cambridge.ma.us, {spdcc|ima|world}!iecc!johnl
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads