search a string in a line and save it in a variable

Hi
I want to read a file line by line and search for a particular string in each line(say for example string containing @ )and save that string into a variable.
Can someone suggest me the way to implement it.I am using K- shell
Thanks
Ishita

var=$(awk '/pattern/')

Ishita,grep -i "error" /var/adm/messages > error.log would search the string "error" in /var/adm/message and would redirect the output to error.log.Remember that it would display the whole line in which the string "error" occurs. `cat error.log` read VALUEI think above code will take care of the variable part. HG

 var=`grep -ho "[a-z]*<String>[a-z]*" Input_file`;echo $var

The above command gives the desired output.

Hi
Sorry guys.I didnt explained my problem clearly.Basically I need to read line by line from an input file and search for two different string in each line.When string 1 is found i need to print it and when string 2 is found i need to save it into a variable.
i tried with below:-
exec 4<input.txt
while read line <&4
do
case $line in
create* ) echo "$line --- Create"
;;
esac
done
exec 4<&-
but it is working only for searching 1 string in the line.Is it possible to modify the above to seach 2 different string in a single line.The input line is something like " Create abc@xyz.com

I am struggling with it from last two days.but didnt got any feasible solution. :frowning:
Can someone suggest me some way to implement it.

Why don't you use grep(1) instead of case ? Use two grep's inside the while loop. One to find the first pattern and second to search for the second pattern(which you can save to a variable).

Also, please surround your code inside code tags for better readability.