help needed in using case statement


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help needed in using case statement
# 1  
Old 01-16-2008
help needed in using case statement

Hi,

I have a script as below:
.......................................................................
rpttxt()
{
name="$*"
awk '/'"${name}"'/ {print $2$3$4 }' file_1.txt
}

title="`rpttxt "TITLE"`"
.........................................................................
The function , rpttext will have arguments that are in the file file_1 and file_2.
The above script searches in file_1 and prints.But I need to use the same function "rpttext" to search in file_1 and file_2 and print accordingly. Its somewaht like below.

file_1 contains :
arg1 abd hju jkl
arg2 nju ghy frg

file_2 contains:
arg3 hju nhy lmd
arg4 rft sed wed

when I call rpttext "arg1" ,
name="$*"
{ if name in file_1 then
print $2 $3
if name in file_2 then
print $3$4

}

can i do this using case statemnt ?


Thanks in advance
JS
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Case statement help

Hi I am new to shell scripting, I wanted to make a shell script that has a case statement asking the user to select their city 1)london 2)tokyo 3) etc., I then want the users input to be stored in a variable and echoed out in another script; so for example if the user selects tokyo, tokyo city code... (2 Replies)
Discussion started by: scriptnewbie
2 Replies

2. Homework & Coursework Questions

Case Statement

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Hey, guys I really need some help with a project. "Write a shell program that examines the command line... (8 Replies)
Discussion started by: sk192010`
8 Replies

3. Shell Programming and Scripting

Case statement

Hello, The standard case statement :- case "$1" in "IE0263") commands;; "IE0264") commands;; esac is it possible to have :- case "$1" in "IE0263" OR "IE0878") commands;; "IE0264") commands;; esac Thanks (4 Replies)
Discussion started by: jmahal
4 Replies

4. Shell Programming and Scripting

case statement

Hi, I am writing case statement to execute some finction, my requirement is once one of the case statement is executed again it has to prompt for the option. for script in `echo "$Script_Selected"` do case $script in 1) getNoOFActUsers ;; 2) moveServerrOORotation ;; ... (2 Replies)
Discussion started by: Satyak
2 Replies

5. UNIX for Dummies Questions & Answers

CASE statement

Hi, I am writing a bash shell script. My script has a few user defined parameters. When the script runs the first thing it does is make sure that these parameters are valid. One of the parameters is called YEAR. A valid input for YEAR can be 1997-2000. One way I have come up with to ensure... (3 Replies)
Discussion started by: msb65
3 Replies

6. Shell Programming and Scripting

case statement

Hi all, I think i'm asking a sqtupid question here.. i'm using case sttament, what is the syntax or symbol for "or"? I thought was || here a quick sample of my case statment echo "Would you like to update your detail ?" read response case $response in ... (2 Replies)
Discussion started by: c00kie88
2 Replies

7. UNIX for Dummies Questions & Answers

If or Case Statement

I want to write a program with the following variables: a=7000 b=24000 c=613.8 The user can enter two words: Vivid or Blue for example. The challenge is that the user might not want to write the words the way they appear. The user can write V or v or vivid or Vivid or write Blue or blue, or B,... (1 Reply)
Discussion started by: Ernst
1 Replies

8. Shell Programming and Scripting

Script needed to select and delete lower case and mixed case records

HELLO ALL, URGENTLY NEEDED A SCRIPT TO SELECT AND DELETE LOWER AND MIXED CASE RECORDS FROM A COLUMN IN A TABLE. FOR EXAMPLE : Table name is EMPLOYEE and the column name is CITY and the CITY column records will be: Newyork washington ... (1 Reply)
Discussion started by: abhilash mn
1 Replies

9. Shell Programming and Scripting

case statement

hi all i'm writing a script and in it i need to prompt the user if the entered value is correct or not ,i wrote the following and its not working ,its executing the script even if i enter Y/N pls any help is appreciated echo "\nAre you sure you entered the right Destination Environment? y :... (5 Replies)
Discussion started by: bkan77
5 Replies

10. Shell Programming and Scripting

case statement

Hi all, is it possible to create a 'dynamic' case statement. ie select option in `ls` do case satement depending on results of the above `ls` done I hope I have explained this ok! Thanks Helen (1 Reply)
Discussion started by: Bab00shka
1 Replies
Login or Register to Ask a Question
SQLSRV_FREE_STMT(3)													       SQLSRV_FREE_STMT(3)

sqlsrv_free_stmt - Frees all resources for the specified statement

SYNOPSIS
bool sqlsrv_free_stmt (resource $stmt) DESCRIPTION
Frees all resources for the specified statement. The statement cannot be used after sqlsrv_free_stmt(3) has been called on it. If sql- srv_free_stmt(3) is called on an in-progress statement that alters server state, statement execution is terminated and the statement is rolled back. PARAMETERS
o $stmt - The statment for which resources are freed. Note that NULL is a valid parameter value. This allows the function to be called multiple times in a script. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 sqlsrv_free_stmt(3) example <?php $serverName = "serverNamesqlexpress"; $connectionInfo = array( "Database"=>"dbName", "UID"=>"username", "PWD"=>"password"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn === false ) { die( print_r( sqlsrv_errors(), true)); } $stmt = sqlsrv_query( $conn, "SELECT * FROM Table_1"); if( $stmt === false ) { die( print_r( sqlsrv_errors(), true)); } /*------------------------------- Process query results here. -------------------------------*/ /* Free the statement resources. */ sqlsrv_free_stmt( $stmt); ?> NOTES
The main difference between sqlsrv_free_stmt(3) and sqlsrv_cancel(3) is that a statement resource cancelled with sqlsrv_cancel(3) can be re-executed if it was created with sqlsrv_prepare(3). A statement resource cancelled with sqlsrv_free_statement(3) cannot be re-executed. SEE ALSO
sqlsrv_cancel(3). PHP Documentation Group SQLSRV_FREE_STMT(3)