Check if file exists and whether it contains a specific string

Viewed 130913

I want to check if file2.sh exists and also if a specific word, poet is part of the file. I use grep to create the variable used_var.

#!/bin/ksh

file_name=/home/file2.sh                  
used_var=`grep "poet" $file_name`    

How can I check if used_var has some value?

5 Answers
Related