The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[sh] String comparison operators userix Shell Programming and Scripting 1 05-16-2008 01:09 AM
string comparison Jatsui Shell Programming and Scripting 5 02-04-2008 12:28 PM
String Comparison between two files using awk rudoraj Shell Programming and Scripting 7 07-25-2006 08:04 AM
string comparison operators, what are they?? ballazrus Shell Programming and Scripting 11 02-13-2006 03:30 AM
String Comparison abey High Level Programming 1 10-19-2005 09:08 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-03-2007
Registered User
 

Join Date: Jul 2006
Posts: 73
string comparison

The script will read a bunch of names, and test if it contains "John", but as below apparently ~ does not work, so what is the easiest way to perform string comparison in bash shell script? thanks

...
elif [ $name~"John"`"]
then
echo "get John"
....
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-03-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Code:
if echo "dfdsdfsaf" | grep -q "sdf" ; then echo s; fi
Reply With Quote
  #3 (permalink)  
Old 01-03-2007
becket's Avatar
Registered User
 

Join Date: Jul 2005
Location: Liege / Belgium
Posts: 36
Code:
if [ $var != ${var/john//} } 
then echo "John is inside :D "
else echo " no ( long ) john here " 
fi
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0