Matching


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Matching
# 1  
Old 12-08-2008
Matching

Can anyone give a sample example of comparing two strings using matching concept in unix shell programming.

say we have two strings,S1 = ravi and S2 = kiran
how can i use matching concept to compare S1 and S2

Can anyone please help me.
# 2  
Old 12-08-2008
# expr hoomer : bart
0
# expr simpson : simpson
7
# 3  
Old 12-11-2008
s1="Ravi"
s2="Kiran"
if [ $s1 != $s2 ]
then
echo "Both are different"
else
echo "Both are same"
fi
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to combine all matching dates and remove non-matching

Using the awk below I am able to combine all the matching dates in $1, but I can not seem to remove the non-matching from the file. Thank you :). file 20161109104500.0+0000,x,5631 20161109104500.0+0000,y,2 20161109104500.0+0000,z,2 20161109104500.0+0000,a,4117... (3 Replies)
Discussion started by: cmccabe
3 Replies

2. Shell Programming and Scripting

Compare file1 for matching line in file2 and print the difference in matching lines

Hello, I have two files file 1 and file 2 each having result of a query on certain database tables and need to compare for Col1 in file1 with Col3 in file2, compare Col2 with Col4 and output the value of Col1 from File1 which is a) not present in Col3 of File2 b) value of Col2 is different from... (2 Replies)
Discussion started by: RasB15
2 Replies

3. Shell Programming and Scripting

Insert lines above matching line with content from matching

Hi, I have text file: Name: xyz Gender: M Address: "120_B_C; ksilskdj; lsudlfw" Zip: 20392 Name: KLM Gender: F Address: "65_D_F; wnmlsi;lsuod;,...." Zip:90233I want to insert 2 new lines before the 'Address: ' line deriving value from this Address line value The Address value in quotes... (1 Reply)
Discussion started by: ysrini
1 Replies

4. Shell Programming and Scripting

Pattern matching

Hi guys I am trying to create a regular expression to match a word with the following pattern: any letter(one or more occurence) followed by a digit(one or more occurence) followed by any letter(one or more occurence) I have tried the following regex but it fails to find what I need: $... (4 Replies)
Discussion started by: aoussenko
4 Replies

5. Shell Programming and Scripting

matching in loop

hello all, this is probably very simple for you guys but i am trying to achive something like below...i have 2 files...file 1 has entries like below DB1:NS DB2:NS DB3:NS DB4 DB5:NS and file2 as below DB1 DB2 DB5 i was to write a loop statment were if there is a matching... (1 Reply)
Discussion started by: abdul.irfan2
1 Replies

6. Shell Programming and Scripting

awk: matching and not matching

Hello all, simple matching and if not match problem that i can't figure out. file1 hostname: 30 10 * * * /home/toto/start PROD instance_name1 -p 00 9 * * * /home/toto/start PROD instance_name2 -p 15 8 * * * /home/toto/start PROD instance_name3 -p hostname2: 00 8 * * *... (5 Replies)
Discussion started by: maverick72
5 Replies

7. UNIX for Dummies Questions & Answers

Matching IF

Hi All, I have a IF loop followed by THEN and a a closing FI.I am trying to find the matching 'FI' for 'IF'.I am wokring on modifying 2000 line code and its become extremely difficult to find the matching of 'IF' manually for on e of the block. Can you guys throw some light please? Thanks... (2 Replies)
Discussion started by: vemana
2 Replies

8. Shell Programming and Scripting

Pattern Matching

Hi Folks, I have the following requirement: I have a file that is containing numerous queries. The tables name mentioned in the queries are in the following format : SchemaName.Tablename. e.g COPDB.TableName. I need to take out all the COPDB.TableName pattern and write it to a different... (6 Replies)
Discussion started by: Siv_Pat
6 Replies

9. UNIX for Dummies Questions & Answers

Pattern Matching

Hi Folks, I have the following requirement: I have a file that is containing numerous queries. The tables name mentioned in the queries are in the following format : SchemaName.Tablename. e.g COPDB.TableName. I need to take out all the COPDB.TableName pattern and write it to a different... (0 Replies)
Discussion started by: Siv_Pat
0 Replies

10. UNIX for Dummies Questions & Answers

Matching string

Hello, i have a program where i have to get a character from the user and check it against the word i have and then replace the character in a blank at the same position it is in the word. (7 Replies)
Discussion started by: nehaquick
7 Replies
Login or Register to Ask a Question