[SOLVED] [SHELL: /bin/sh] For loop using variable variable names
Simple enough problem I think, I just can't seem to get it right.
The below doesn't work as intended, it's just a function defined in a much larger script:
The else statement won't exist once I've successfully tested it. The output I see when I run the actual script is:
What I expect to see in the above is the value of those variables (Which is just a string of text assuming non-zero length).
Kindly note that I need it to be /bin/sh compliant, as it'll be going across multiple Linux/Unix platforms.
Last edited by Vryali; 06-06-2012 at 11:47 AM..
Reason: Clarity
I am a newbie to awk and c programming, however am not a unix newbie. However, I do need help with a kshell script I am writing. It is almost complete, the last step is killing me. Any help would be greatly appreciated. What I am trying to do is cat a text file that has usernames. Then, using... (2 Replies)
Hi All ,
I am having confusion in a shell script. Please guide me.
I need to get multiple files (number of files vary time to time, file names are separated by '|') using FTP get from the remote server.
Actually, i call the FTP function in a loop. At the last step, i need to move all the get... (3 Replies)
Hello,
I have this:
#!/usr/bin/ksh
V1=ABC
str="hello 123;${V1}"
eval "echo $str"
i get
hello 123
/script.sh ABC not found
However eval works if $str variable doesn't contain a semicolumn (eg if str="hello 123~${v1}"
running the eval statement above would produce (2 Replies)
Hi,
I'm trying to use a config file to define frequencies for checking log files. If the config file contains a frequency it will be used else a default value. The format of the config file (and hence the environment variable) is
FREQ_log_logname=value
A test shell script as below:... (2 Replies)
I'm using korn shell and I am wondering if it's possible to use a parameter passed into a function to build a variable name in a configuration file. I have the function in one source file, I'd like to have a global configuration file instead of hardcoding logins to each script.
So I have a... (7 Replies)
Hi All,
I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
i=0
while
do
sizesfor0=`cat 16 | grep 'pickSize' -A 1 | grep '_sz' | cut -d'_' -f1`
sizesfor0=${sizesfor0//id=\"lll/:}
IFS=: array0=( $sizesfor0 )
echo ${array0}
i=$(( $i + 1 ))
done
So, right now I have two variables in the while statement above
sizesfor0 and array0
The... (1 Reply)
hi,
when we assign a variable inside a for loop or while loop in a shell script, does it loses its value after comming out of the loop. i am facing this issue.
can anyone help me?? (8 Replies)
Hi guys
I'm a beginner in fortran. So excuse me for my naivety, let me briefly describe what I was trying to do. I have let's say 2 files named reac-1 and reac-2. After opening these files I've to do some calculations, close these files and open the same files again in a loop. So my faulty code... (6 Replies)
I want to create a shell script to add a user and modify its comment field mentioned in a file.
1.
File value:-
username comment field value
xyz123 xyztesting
abc123 abctesting
def123 deftesting
2. i am using below loop to create user... (2 Replies)
Discussion started by: Anil
2 Replies
LEARN ABOUT PLAN9
games
GAMES(1) General Commands Manual GAMES(1)NAME
4s, 5s, ana, mandel, plumb, smiley, life, fsim, clock, catclock, fireworks, swar, festoon - time wasters
SYNOPSIS
games/4s
games/5s
games/ana [ fixwords ]
games/mandel
games/plumb [ level ]
games/smiley
games/life startfile
games/fsim
games/clock
games/catclock [ -c ]
games/fireworks
games/swar
games/festoon [ -p ] [ -e ] [ -t ] [ -sseed ] [ len ] [ pfn ]
DESCRIPTION
There are a few games in /bin/games:
4s, 5s Try to fill complete rows using 4-square or 5-square tiles. Move tiles left or right by moving the mouse. Rotate tiles with
buttons 1 and 3. Drop tiles for more points with button 2 or the space bar.
ana Find anagrams for words typed on standard input. Anagrams can contain several dictionary words. The fixwords argument or num-
bers typed on standard input fix the number of words in the output anagrams.
mandel Compute and display Mandelbrot sets. Menus on the mouse buttons control various things.
plumb Build a plumbing system. Keep ahead of the advancing oil and don't waste pipe. The level argument lets you start at a harder
level.
smiley A game of historical importance. Type space to shoot, comma to move left, and period to go right.
life Play the game of life, given an initial position. There is a library of interesting initial positions; the library is consulted
if startfile cannot be found.
fsim Pretend you're flying a Cessna.
clock, catclock
Display analog clocks. Option -c makes catclock crosseyed.
fireworks Hoist the fiery blue peter.
swar Space war for two players called MCI and SPRINT. One player types a or d to turn left or right, s to shoot, x to enter hyper-
space, and w to accelerate. The other player uses ;, l, . and o. AT&T scores whenever either ship shoots itself or otherwise
causes mayhem. Hyperspace is occasionally fatal.
festoon Traditional radical monoarchate qualitativeness. Now produces pictures (-p), tables (-t), and equations (-e). The seed can be
set to recreate a specific document. Len is sentence length, and pfn is percent faked nouns (default 0).
FILES
/sys/games/lib/4scores
scores of 4s games
/sys/games/lib/5scores
scores of 5s games
/sys/games/lib/plumb/scores
scores of plumb games
/sys/games/lib/anawords
used by ana
/sys/games/lib/plumb/*
miscellaneous files used by plumb
/sys/games/lib/life/*
interesting starting positions
SOURCE
/sys/src/games
GAMES(1)