![]() |
|
|
|
|
|||||||
| 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 |
| #!/bin/sh script fails at StringA | tr "[x]" "[y]" | by_tg | UNIX for Dummies Questions & Answers | 3 | 02-22-2008 09:17 AM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-19-2007 10:52 PM |
| split the string "Setview: arv-temp-view" | amitrajvarma | Shell Programming and Scripting | 2 | 10-11-2007 02:14 AM |
| grep/cat/more -- search in a txt file and display content from a specific "keyword" | I-1 | UNIX for Dummies Questions & Answers | 4 | 02-21-2007 01:57 AM |
| Block ";" in input string | beilstwh | High Level Programming | 10 | 06-21-2006 12:02 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
search excat string in another string (grep "fails")
hello,
i have an statement which i have to correct because it shows the wrong result. i want to search an excat string in another string, command "grep" shows the wrong result: example: STRINGS="string1 string2 string3" search_string="string" incorrect: if [ `echo "${STRINGS}" | grep "${search_string}" > /dev/null 2>/dev/null; \ echo $?` -gt 0 ] then echo "not found" fi my solution will be a "for statement": exists="N" for string in ${STRINGS} do if [ "${string}" = "${search_string}" ] then exists="J" break fi done echo $exists is there any solution with one command. i will use in a shell script, also it possible to use perl for this but my experience in perl is very small ... regards |
|||
| Google The UNIX and Linux Forums |
| Forum Sponsor | ||
|
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|