Pages

Text

Recent Articles

Nike Sports

Ads 468x60px

Recent Posts

Google Plus

Download

Thursday, 12 April 2012

Write a shell script that reads a pattern and a file name from the keyboard, if the file exist then pattern should be search on the file and display accordingly where the pattern is matched otherwise display file not found.

#! /bin/sh
# Write a shell script that reads a pattern and a file name from the keyboard, if the file exist then pattern should be search on the file and display accordingly where the pattern is matched otherwise display file not found.
echo " Enter the file name "
read filename
if ls $filename
then
echo "enter the pattern "
read pattern
grep $pattern $filename
else
echo " File doesn't exist "
fi

0 comments:

Post a Comment