Sponsored Content
Full Discussion: Array in ksh with if-else
Top Forums Shell Programming and Scripting Array in ksh with if-else Post 302599376 by saps19 on Friday 17th of February 2012 01:53:02 AM
Old 02-17-2012
Quote:
Originally Posted by aigles
First, there are missing $ in your script :
Code:
if [ "$varSSCode" == "11" -o "$varSSCode" == "56" -o "$varSSCode" == "93" ]; then

Thanks for the heads-up.. I really missed it..!

Quote:
A possible solution (using a list of values, not an array) :
Code:
#!/usr/bin/ksh

validCodes=",11,56,93,"

read varSSCode?"Source System Code: "
if [[ "${validCodes}" == *,${varSSCode},* ]]

Jean-Pierre.
Apologies for the delay in replying. Due to unavailability of UAT Server, I was not able to test the script.

But now, I've tested it and works fine with list of values.

Thanks a lot Jean.

Cheers,
Saps
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tokenising into array (KSH)

Greetings all, I've been getting a little frustrated over my scripts as I'm not too experienced with powerful commands such as awk and sed. Hope to find some guidance here. I need to extract the names of all directories within a specified directory, grab their names and then place each name... (5 Replies)
Discussion started by: rockysfr
5 Replies

2. Shell Programming and Scripting

[KSH] Split string into array

Hi, Is there any way to convert a string into an array in KSH? In other words I want to split the string like this: STRING="one two three four" into an array of 4 values splitting on white space. The array should be similar to the one that would be created with the following command: ... (3 Replies)
Discussion started by: piooooter
3 Replies

3. Shell Programming and Scripting

using array in ksh

hi all, need help with putting names in an array, i have a few servers which i look up by doing a 'find . -name "*.pid' and the format of the output is like following : ./servername/myserver.pid i was wondering how can i iterate through and store each name in one array my code is... (1 Reply)
Discussion started by: cesarNZ
1 Replies

4. Shell Programming and Scripting

Ksh array solution.

I was wondering if ksh supported arrays. I have a script that may work with several hosts. I'd like a means of knowing how many hosts I'm working with and an easy way to access them (as variables) in a loop. I'm assuming there's some kind of foreach in shell scripting. (1 Reply)
Discussion started by: mrwatkin
1 Replies

5. UNIX for Advanced & Expert Users

Array copy in ksh

Hi all, Following code in ksh is giving error: fileLimit=5 func(){ dir="$1" format="$2" array="$3" i=0 ls -lrt $format | tail -${fileLimit} | while read f_det; do files="${f_det}," ((i+=1)) done eval $(echo set -A $array '"${files}"') } func "." "*.pl" "a" echo... (10 Replies)
Discussion started by: PRKS
10 Replies

6. UNIX for Dummies Questions & Answers

Need help with KSH Array assignment

The following command is only intermittently successful, depends on the data I give it: set -A ImageShifts_sorted `awk '/START_SECTION IMAGE_DEFINITION/ {getline;getline;getline;getline; print $2"-"$3}' temp.ASCII | sort -u` My Error: set: -1: unknown option Finally, If I run that... (3 Replies)
Discussion started by: nerdcurious
3 Replies

7. Shell Programming and Scripting

ksh insert element in array

Hi all, I need help with the following scenario in ksh. If the number of elements contained by arrayA is 11 I need to insert a zero as the element arrayA then print all arrayA elements separated by comma. Appreciate your help. (9 Replies)
Discussion started by: ejianu
9 Replies

8. UNIX and Linux Applications

Array in Ksh

Hi Guys, My code is something like this set -A A1 1 7 13 19 set -A A2 2 8 14 20 set -A A3 3 9 15 21 echo "Enter a number" read number for i in 0 2 3 4 do if }" ] then do something elif }" ] then do something elif }" ] then do something (4 Replies)
Discussion started by: jeanzibbin
4 Replies

9. Shell Programming and Scripting

[Solved] KSH: Array/If Help

RedHat 5 KSH I am creating an array, and then using case to go through and count for specific words. Then the count gets stored as an expression. string='ftp rcp rsh telnet ftp ftp' set -A myarray $string FTPCOUNT="0" for command in ${myarray} do case $command in ftp) FTPCOUNT=`expr... (2 Replies)
Discussion started by: nitrobass24
2 Replies

10. Shell Programming and Scripting

Assigning * as value in a ksh array

I want to extract each and single character from a password string and put it in an array. I tried this : set -A password "echo $passwd | awk '{for (i=1; i<=length($1); i++) printf "%s ",substr($1,i,1)}'` It's working as long that the password string doesn't contains any * I tried a few... (5 Replies)
Discussion started by: ce9888
5 Replies
set_color(1)                                                           fish                                                           set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 03:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy