This is just a reminder for myself. Usually I have to look this up in Google whenever I want to use it 🙁
Check if string A contains string B:
if [[ $A == *"$B"* ]]
then
echo We have a hit
else
echo No hit
fi
Check if a variable A is a number:
if [ "$A"=~"^[0-9]+$" ]
then
echo Variable contains only digits
else
echo This is not a number
fi
About Juergen Caris
I am 54yo, MSc(Dist) and BSc in Computer Science, German and working as a Senior Server Engineer for the NHS Lothian. I am responsible for the patient management system, called TrakCare. I am a UNIX/Linux guy, working in this sector for more than 20 years now. I am also interested in robotics, microprocessors, system monitoring, Home automation and programming.