Date: Wed, 10 Feb 2016 04:58:16 -0800 From: Sergei G <sergeig.public@gmail.com> To: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: /bin/sh starts with check in script Message-ID: <56BB33E8.4080900@gmail.com>
next in thread | raw e-mail | index | archive | help
I came up with this solution to check if variable $line starts with a hash. Basically I am checking if line is a comment in the configuration file. #!/bin/sh if expr "${line}" : '#.*' > /dev/null; then echo Ignoring comment line fi I had to redirect to /dev/null, because expr prints a number to STDOUT. Is there a better way to do this kind of string matching check in /bin/sh (not bash)? Thanks
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?56BB33E8.4080900>