Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Shell Script to display the exit status using grep command which search a string from a string

Posted By: Phoebe Brown     Category: Unix / Linux / Ubuntu     Views: 5579

Write a Shell Script to display the exit status using grep command which search a string from a string.

Code for Shell Script to display the exit status using grep command which search a string from a string in Unix / Linux / Ubuntu

echo "for the exit status"
read file1 string
grep $string $file1
echo "the status is "$?
if [ $? -eq 0 ]
 then
    echo " succeed"else
        echo "not succeed"
fi
echo "completed"

OUTPUT
**********
[04mca58@LINTEL 04mca58]$ sh exitstatus.sh
for the exit status
database xyz1
01      xyz1 1000    12-08-2002
the status is 0
 succeed
completed
  
Share: 



Phoebe Brown
Phoebe Brown author of Shell Script to display the exit status using grep command which search a string from a string is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!