The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
First letter of each Word from a line maxmave Shell Programming and Scripting 5 04-15-2008 07:52 PM
How to filter the words, if that word contains the expected letter venu_eie UNIX for Advanced & Expert Users 3 03-19-2008 01:00 PM
find a word in a file, and change a word beneath it ?? vikas027 Shell Programming and Scripting 2 02-13-2008 04:23 PM
how to move word by word on command line pbsrinivas UNIX for Dummies Questions & Answers 1 11-23-2007 06:17 AM
Can a shell script pull the first word (or nth word) off each line of a text file? tricky Shell Programming and Scripting 5 08-17-2006 06:29 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-05-2008
Furqan_79 Furqan_79 is offline
Registered User
  
 

Join Date: May 2008
Posts: 6
matching a letter in a word

hi,

if i have a string of letters and seperatly i have a single letter. how do i check whether that specific letter is in my string aswell? any ideas?
  #2 (permalink)  
Old 06-05-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
One way - the && || stuff acts like an "if then else"
Code:
string="plplqabl fghj"
myletter="a"
echo "$string" | grep -q "$myletter"  && echo "$myletter found" || echo "$myletter not found"

myletter=x
echo "$string" | grep -q "$myletter"  && echo "$myletter found" || echo "$myletter not found"
  #3 (permalink)  
Old 06-05-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 741
Another...

Code:
STRGZ="hello world!!!"
LTR="w"
echo $STRGZ |  awk -vc="$LTR" '{if(gsub(c,"")) print "Found";else print "Not Found"}'
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 02:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0