So, I have a script setupPrograms.sh that I run after the first boot of a new install of CentOS 7 that maps network drives, sets up repos, installs commonly used apps on my network, and more - it works great. Well, almost. I had to comment out the 'test' for CentOS 7 because it ALWAYS failed from within the script, but returned a result from the command line.
My test for CentOS 7 was:
Code: Select all
if [ grep VERSION_ID=\"7\" /etc/os-release ]
then
If I copy the text between the brackets to the command line and execute it, I always get the (red) version info. If I create (I did) a separate bash script with that condition, it ALWAYS evaluates to false (executing the ELSE statements in the script) and complains
/scripts/versionTest.sh: line 1: [: VERSION_ID="7": binary operator expected
Script (tried multiple times escaping/un-escaping non-alpha characters to no avail):
Code: Select all
if [ grep VERSION_ID=\"7\" /etc/os-release ]
then
echo Version found!
else
echo Failed for some reason!
fi
I know I've done something stupid - the binary thing is throwing me - I even tried escaping the "-". What does BASH want in my script(s) that's OK from the command line?
Thank you.