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?
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?
One way - the && || stuff acts like an "if then else"
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"
Another...
STRGZ="hello world!!!"
LTR="w"
echo $STRGZ | awk -vc="$LTR" '{if(gsub(c,"")) print "Found";else print "Not Found"}'