Sponsored Content
Top Forums Shell Programming and Scripting String compare in shell script Post 302262858 by kiranlalka on Saturday 29th of November 2008 08:39:29 AM
Old 11-29-2008
Quote:
Originally Posted by Christoph Spohr
Hi,

-eq is meant to compare numbers. Try "=" or "=~" depending on what you
want to achieve. For further information:

Code:
man test

HTH Chris

Thx it worked.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script cant recognize if else compare

hi I face the problem the if else statement dint return correct result for me my script as below: #!/bin/ksh sqlplus -s /nolog <<EOF connect databaseuser/password column num new_value num format 9999 set head off select count(*) num from table1; exit num EOF if ; then echo "$?"... (6 Replies)
Discussion started by: jaseloh
6 Replies

2. Shell Programming and Scripting

compare two tables using shell script

Hi, I want to compare two tables fieldwise using shell script. Can anyone help me regarding the same. The approach which i tried is to first move the two tables in simple txt file where each field is now seperated by space. But i can't retrive each field with "space" as a seperator b'coz there... (1 Reply)
Discussion started by: dtidke
1 Replies

3. UNIX and Linux Applications

How to compare two files using shell script

hi experts please help me to compare two files which are in different directory file1<file will be master file> (/home/rev/mas.txt} ex x1 x2 file2 <will be in different folder> (/home/rev/per/.....) ex x3 x4 the filesinside per folder i need to compare with master file... (1 Reply)
Discussion started by: revenna
1 Replies

4. Shell Programming and Scripting

how to compare two lines using shell script?

how to compare two lines using shell script? (1 Reply)
Discussion started by: suman_dba1
1 Replies

5. Shell Programming and Scripting

String compare with list in shell script

Hi , I am new to shell scripting. below is my requirement : 1) while running my .sh i will pass a string 2) i have to extract a folder name under a /config folder 3) i need to compare a input string in the folder name list 4) if that is true i have to continue my job else i have to... (2 Replies)
Discussion started by: rajinavaneethan
2 Replies

6. Shell Programming and Scripting

Shell Script to Compare Two Files

I have a directory with about 6 files that we receive regularly. these 6 files contain information for 3 different units, 2 for each unit. files related to a specific unit are named similarly with a change in number at the end of the file. the numbers should be sequential. for each grouping of... (3 Replies)
Discussion started by: scriptman237
3 Replies

7. Shell Programming and Scripting

Shell script to compare two files

I have two files; file A and file B. I need all the entries of file A to be compared with file B line by line. If the entry exists on file B, then save those on file C; if no then save it on file D Note :- all the columns of the lines of file A need to be compared, except the last two columns... (8 Replies)
Discussion started by: ajiwww
8 Replies

8. UNIX for Dummies Questions & Answers

Comparing a String variable with a string literal in a Debian shell script

Hi All, I am trying to to compare a string variable with a string literal inside a loop but keep getting the ./testifstructure.sh: line 6: #!/bin/sh BOOK_LIST="BOOK1 BOOK2" for BOOK in ${BOOK_LIST} do if then echo '1' else echo '2' fi done Please use next... (1 Reply)
Discussion started by: daveu7
1 Replies

9. Post Here to Contact Site Administrators and Moderators

Want a tcl script to compare a string in a file ignoring white spaces

Hi , I want a tcl script to search a string ignoring whitespaces in a .log file . It should correctly match . The string are as follows "Output-Maps 1 1 0 0 0" 1 and Active Intermediate-Maps 0 0 0 ... (1 Reply)
Discussion started by: kulua
1 Replies

10. UNIX for Beginners Questions & Answers

Concatenate a string and number and compare that with another string in awk script

I have below code inside my awk script if ( $0 ~ /SVC IN:/ ) { svc_in=substr( $0,23 , 3); if (msg_start == 1 && msg_end == 0) { msg_arr=$0; } } else if ( $0 ~ /^SVC OUT:/ ) { svc_out=substr( $0, 9, 3); if (msg_start == 1 && msg_end == 0) ... (6 Replies)
Discussion started by: bhagya123
6 Replies
DB2_ESCAPE_STRING(3)							 1						      DB2_ESCAPE_STRING(3)

db2_escape_string - Used to escape certain characters

SYNOPSIS
string db2_escape_string (string $string_literal) DESCRIPTION
Prepends backslashes to special characters in the string argument. PARAMETERS
o $string_literal - The string that contains special characters that need to be modified. Characters that are prepended with a backslash are x00, , , , ', " and x1a. RETURN VALUES
Returns $string_literal with the special characters noted above prepended with backslashes. EXAMPLES
Example #1 A db2_escape_string(3) example Result of using the db2_escape_string(3) function <?php $conn = db2_connect($database, $user, $password); if ($conn) { $str[0] = "All characters: x00 , , , , ' , " , x1a ."; $str[1] = "Backslash (). Single quote ('). Double quote (")"; $str[2] = "The NULL character must be quoted as well"; $str[3] = "Intersting characters: x1a , x00 ."; $str[4] = "Nothing to quote"; $str[5] = 200676; $str[6] = ""; foreach( $str as $string ) { echo "db2_escape_string: " . db2_escape_string($string). " "; } } ?> The above example will output: db2_escape_string: All characters: , , , \ , ' , " ,  . db2_escape_string: Backslash (\). Single quote ('). Double quote (") db2_escape_string: The NULL character must be quoted as well db2_escape_string: Intersting characters:  , . db2_escape_string: Nothing to quote db2_escape_string: 200676 db2_escape_string: SEE ALSO
db2_prepare(3). PHP Documentation Group DB2_ESCAPE_STRING(3)
All times are GMT -4. The time now is 01:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy