I have done with some conditions but not able to use exact syntax to check more than 3 condition from file.
I am able to do multiple grep from file but not able to add 3 pattern with conditions. like below.
you can provide CASE/Loop/if-else(ladder syntax. I just want print user friendly msg to user when the user runs this script instead pattern which are found in startup.log file. and those user friendly msg should depend on what pattern found in startup.log
Suppose I found pid already exists when I fire above command in startup.log then I want to print echo "DB services already running" like this
pg_ctl -D $PGDATA start > startup.log
if [$? -eq 0]
then
#if db services is stopped priviously, then it will start and grep below msg to user
ls -t postgresql*.log | head -n1 | args grep "Database for read only connections"
else
elif grep 'word1|word2|word3' startup.log
then
#if above word1 exists in file it should print below msg
echo "hello"
else
#if word2 is present in file it shhould print below msg
echo " world"
and one more contion i want to add like below
#if word3 is exists in the file it should below msg
echo "postgresql"
If you could provide 1 simple example, I really appreciate for that because, I have tried syntax but not able to resolve the issue.
postgressql*.log
a typo or is the extras
deliberate? – cas Jul 18 '21 at 13:39