Reputation: 13
This is the code:
#!/bin/bash
title='Unix Shell Programming'
read search_word
if [[ $title =~ $search_word ]]
then
echo Yes - matchli
else
echo No - match
enter code here
fi
I want to substitute the $title
to a file called emplist. Is it possible? And how can I do that? Thank you!
Upvotes: 0
Views: 49
Reputation: 1783
You can use grep
like this:
if grep -q "$search_word" emplist
then
# $search_word was found inside the file emplist
Upvotes: 0
Reputation: 1406
add these lines in your shell script,
echo "enter file name with extension"
read fname
cat $fname
Upvotes: 1