Comments on: How to Compare Numbers and Strings in Linux Shell Script https://www.linuxtechi.com/compare-numbers-strings-files-in-bash-script/ Sun, 13 Sep 2020 16:48:36 +0000 hourly 1 By: BarryP https://www.linuxtechi.com/compare-numbers-strings-files-in-bash-script/#comment-20449 Fri, 29 May 2020 10:02:57 +0000 http://www.linuxtechi.com/?p=5487#comment-20449 In reply to BarryP.

Think I figured it out… tried with [[ ]] … seems to be good like that 🙂

]]>
By: BarryP https://www.linuxtechi.com/compare-numbers-strings-files-in-bash-script/#comment-20440 Thu, 28 May 2020 20:45:19 +0000 http://www.linuxtechi.com/?p=5487#comment-20440 If number is 6 and want to test if greater than, using -gt up until 9 is fine, over, like 10 as the base number, then it fails. Why?
Example:
NUM=6
if [ “$NUM” -gt “10”]
echo “$NUM is higher than 10”
else
echo “$NUM is lower than 10”
fi

]]>
By: dinosore https://www.linuxtechi.com/compare-numbers-strings-files-in-bash-script/#comment-17372 Thu, 28 Nov 2019 14:01:13 +0000 http://www.linuxtechi.com/?p=5487#comment-17372 Solution is simple , when using any of these symbols in scripts, they should be used with escape character i.e. use it as “/>” or “/<“.
I think you meant to escape with a left oblique stroke rather than a right one (\ not /).

]]>