Sponsored Content
Full Discussion: If [ ] or not?
Top Forums Shell Programming and Scripting If [ ] or not? Post 303027263 by MuntyScrunt on Wednesday 12th of December 2018 03:30:29 PM
Old 12-12-2018
If [ ] or not?

As far as I can see from all the examples I can find the following is correct:

if [ "$x" = "valid" ]; then

So, if that's how an if has to work, and a command should be within "$(command)" why does the following work:

if pgrep process; then
echo "Yes"
else
echo "No"
fi

I know that returns a number, but you'd check for a number in the first example. I'm fine with it working, that doesn't bother me, I just want to understand why.

Many thanks.
 
All times are GMT -4. The time now is 04:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy