Verify input parameter is in the list


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Verify input parameter is in the list
# 1  
Old 04-24-2014
Verify input parameter is in the list

I need write a Korn shell which accept input parameter. But this input paramter must match one of the string in an existsing file (listkeyword). Can someone one help, how this can be done ?
# 2  
Old 04-24-2014
What do you have so far?
# 3  
Old 04-24-2014
Perhaps something like this:

Code:
#!/usr/bin/env ksh

read SOMEINPUT?"Enter your input: "
FILE="/tmp/somefile"
if [[ $(grep -i -c $SOMEINPUT $FILE) -ge 1 ]]; then
    echo "$SOMEINPUT exists in $FILE."
else
    echo "No match found for $SOMEINPUT in $FILE."
fi

# 4  
Old 04-24-2014
Might be worth storing the list in a variable and running a select loop on it
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace value from input parameter

Hi Guys, I am having a script file where in getting input parameter as string. I need to assign the variable but not able to achieve #!/bin/bash input=$1 replace=string_$input_string2 echo $replace I am getting but should get string_<input_value>_string2 string_ (1 Reply)
Discussion started by: rohit_shinez
1 Replies

2. UNIX for Beginners Questions & Answers

Need list of input and output parameter of task in a text file, using shell script

//file begin ===== //some code task abcd_; input x; input y,z; //some comment output w; //some comment reg p; integer q; begin //some code end endtask : abcd_ //some code //file end ===== expected output from above... (1 Reply)
Discussion started by: rishifrnds
1 Replies

3. Shell Programming and Scripting

Bash to verify each line in input for specific pattern

In the bash below the out put of a process is written to input. What I am trying to do is read each line in the input and verify/check it for specific text (there are always 6 lines for each file and the specific text for each line is in the description). There will always be 6 lines in each... (5 Replies)
Discussion started by: cmccabe
5 Replies

4. Shell Programming and Scripting

Verify the input

I run the script with one parameter : myscript abc002 But I need my script to check the parameter in txt array first: txt="abc001 abc002 abc004" What's the best way to do it? I am using ksh. #! /usr/bin/ksh txt="abc001 abc002 abc004" if ; then echo " Your input is wrong,... (9 Replies)
Discussion started by: newoz
9 Replies

5. Shell Programming and Scripting

Check input parameter

Hi all i need to check that if user has passed any input parameter while executing he shell script like ./test1.sh -a"-v" then do smothing if user execute the script without giving input paramater then ./test1.sh then do something how can we check this input parameter (6 Replies)
Discussion started by: aishsimplesweet
6 Replies

6. Shell Programming and Scripting

Bash Script verify user input is not empty and is equal to a value

I need to create a script that has a user enter a value. I want to verify that the value is either 1,2, or 3. If it is not then I want them to try entering it again. I am using a while loop to force them to retry. I am able to test the input against 1,2, and 3, but when I test agains an... (4 Replies)
Discussion started by: spartiati
4 Replies

7. Shell Programming and Scripting

Verify input parameters

I have to write a script to verify input parameters; say esr should be YES or NO other wise the script should print an error. This is what i tried in my script but I get the following error : esr="YES" if ; then print " Error should specify esr options YES/NO" else esr =$esr fi ... (2 Replies)
Discussion started by: ramky79
2 Replies

8. Shell Programming and Scripting

How to Get the File Input from Parameter

pdir=`pwd` if ; then echo current directory $pdir ls -altr echo fi for f in $* do # directory if ; then echo current directory $f cd $f ls -latr echo fi # but you can test file/dir # regular file only if ; then echo... (4 Replies)
Discussion started by: wtolentino
4 Replies

9. Shell Programming and Scripting

awk/input parameter

Hi, My script takes in one input parameter($1-email id) on the command line... The script contains something like this... awk '$1 == 400' abc.log >def.log mail -s subject $1 <def.log abc.log looks something like this... 300 222 330 123 445 400 098 890 727 663 How do i make the... (3 Replies)
Discussion started by: wannalearn
3 Replies

10. Shell Programming and Scripting

Input parameter format

Hi, My script expects 2 inputs and one of them is supposed to be time, I would like to check if the given input is in validate format (i.e. 16:00), could anyone help me out here? thanks! (1 Reply)
Discussion started by: mpang_
1 Replies
Login or Register to Ask a Question