Originally Posted by
FakeOutdoorsman
I can't figure out how to get the 2.8.5 from $wp_version = '2.8.5'; so I can apply it to the curl command.
How about something like this to get the version:
PHP Code:
version=$(curl -s http://core.svn.wordpress.org/trunk/wp-includes/version.php | awk -F\' '/^\$wp_version/{print $2}')
Originally Posted by
FakeOutdoorsman
Also, a few more questions. Should I be using != or -ne?
!= is for comparing strings so it's what you should be using in this particular instance. -ne is for comparing integers.
Originally Posted by
FakeOutdoorsman
What is the difference between ${foo} and "$foo"?
${foo} is used when you want to clearly delineate variables. Let's say that foo=123, and you want to echo the value of foo plus the word "bar". You might do something like "echo $foobar". Bash will interpret that as the variable foobar and either return the value of $foobar if it's set or nothing at all if it's not. "echo ${foo}bar" will actually echo 123bar. Note that if you use the braces syntax, you still have to quote a variable to maintain spaces. See this example:
PHP Code:
$ foo="bar baz"
$ echo $foobar
$ echo ${foo}bar
bar bazbar
$ if [ ${foo} == "bar baz" ];then echo True; fi
bash: [: too many arguments
$ if [ "${foo}" == "bar baz" ];then echo True; fi
True
#Just to demonstrate different comparison operators:
$ if [ "${foo}" -eq "bar baz" ];then echo True; fi
bash: [: bar baz: integer expression expected
Bookmarks