Write a shell script that searches the file contents in a directory and its sub-directories for a text string given by the user. It list all such file names having that given string and store in a temp file "search_temp". It should have user friendly messages e.g. "File does not exit" , "Do you want to search again", etc.
#bin/bashread-p"Enter a filename:"filename
if
[[
-f $ Search_temp]]
;
then echo
"The file $ Search_temp exists."read –p
"Enter the you word want to find:"
Word
grep "$word"
"$Search_temp"
else echo "The file $filename does not exist ".
fi
SUCCESS=0
E_NOARGS=65
If
[-z"$1"]
then
echo"Usage:basename
$0'rpm-file"
exist $E_NOARGS
fi
{
#Begin code block.
echo echo"Archive Description:"
rpm-qpi $ 1 # Query descri....
echo echo"Archive Listing:"
rpm-qpl $ 1 # Query listing
echo rpm-i—test $ 1 # Query whether rpm file can be installed.
If ["$?" – eq $ SUCCESS]
then
echo "$1 can be installed."
else
echo "$1 cannot be installed."
Fi
echo #End code block.
}> "$1.test" #Redirects output of everything in block of file.
echo "Result of rpm test in file $1.test"
#See rpm main page for explanation of options.
exit 0.
exits = $(grep-c$word$file)
if
[[$exits-gt0]];
then
echo"File does not exit"
fi
0 comments:
Post a Comment
Let us know your responses and feedback