![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to search a word | pvr_satya | Shell Programming and Scripting | 3 | 08-04-2008 11:24 AM |
| To find a character immediately following a word | The Observer | Shell Programming and Scripting | 2 | 07-11-2008 04:21 AM |
| Convert character in word to CAPS?? | vadharah | Shell Programming and Scripting | 3 | 04-01-2008 04:44 AM |
| Change Position of word character | cedrichiu | Shell Programming and Scripting | 6 | 03-11-2007 10:52 PM |
| Grep for X character on a word | jjoves | UNIX for Dummies Questions & Answers | 5 | 08-06-2004 02:14 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
to search for a particular character in a word
Hi
I would like to accept in a string from user like username/pwd@dbname suppose the user does not input @ then i should throw an error that @ symbol missing . How to achieve this Thanks in advance Suresh |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
you can use this
Code:
echo "enter username and password" read var echo "$var"|grep "@" >> /dev/null if [ $? -ne 0 ];then echo "no \"@\" found";else echo "\"@\" found";fi |
|
#3
|
|||
|
|||
|
Quote:
Code:
#!/bin/bash read -p "Enter username and password: " var if [[ $var =~ "@" ]] then echo 'found @' else echo 'no @ found' fi |
|
#4
|
|||
|
|||
|
the use of regular expression in bash =~ is also not necessary
Code:
case $input in *@*)
echo "there"
echo "do something here"
;;
esac
|
|
#5
|
|||
|
|||
|
Thanks guys for
|
|
#6
|
|||
|
|||
|
Thanks guys for ur replies
|
|
#7
|
|||
|
|||
|
Sorry for asking late actually i need to check for / also apart from @
I am using echo "$var"|grep "@" >> /dev/null as this worked for me if i do like echo "$3"|grep "\/*@" >> /dev/null i am not getting desired result is there another way Thanks in advance |
|||
| Google The UNIX and Linux Forums |