Now I am trying to get the exit stat ($?) of 1 if any text is found and 0 if any text is not found using grep, i.e. just reversing the exit status of grep
cmd || true will always return 0, since either cmd succeeds or true does. In your snippet #1, cmd is grep && false. That is always false, since either grep fails or false does.
Your snippet #1 therefore reduces to false || true. That will always return 0.
Since your grep command succeeds:
Regards,
Alister
I think(hope) I've got a simple one - I just need to send an email if a mysql query returns any results (ideally - it will never match).
Currently I just pipe the mysql query output to the mail program, but of course that emails regardless of the output( and I check this every 10 minutes from... (5 Replies)
I want to let sleep 3 in the background and echo $i
pkglists="a b c d e f g"
f()
{
local i
set -- $pkglists
&& ((i +=2)) && sleep 3 &;echo $i
}
f (3 Replies)
Hi,
Does anyone know any way of making bash prompt extended with conditional content?
Example:
export PS1="] && echo '#' || echo '\$'" # This won't work - prompt is not executed
# export PS1="\$" # This is an existing but also working equivalent
I would like to use more complex... (8 Replies)
I want to combine 2 conditional statements by using -o in bash, but it won't work.
if ; then
echo "The number needs to be between 0 and $nr"
fi
Each time i execute the file it says:
./selectCitaat: line 10: syntax error near unexpected token `$1' (3 Replies)
Hi, I am a nbee to Unix, I have used following script to check my tomcat is running or not and restart if it down. but actually it restart my tomcat each time running even my tomcat still running fine:
Script that can run a check and perform an action if the check fails
... (1 Reply)
hi,
please point out what's wrong with my script. im feeding it a list containing fqdn, sit should ssh into each and verify that atleast one of its virtual backup ip resolves into one of its virtual hostnames .. anyway the objective shows in the script... however, im having problems in the ... (4 Replies)
Hi, first post, so hello to all.
I have a Bash scripting problem that is driving me a bit nutty.
It involves a program called 'convert' which is part of the ImageMagick collection.
Normal usage from the commandline is:
$ convert -resize 120x120 inputfile.jpg outputfile.jpg
This is... (7 Replies)