regex - How to write and match regular expressions in /bin/sh script? -
i writing shell script limited unix-based microkernel doesn't have bash! /bin/sh can't run following lines reasons.
if [[ `uname` =~ (qnx|qnx) ]]; read -p "what dev prefix use? " dev_prefix if [[ $dev_prefix =~ ^[a-z0-9_-]+@[a-z0-9_-"."]+:.*$ ]];
for 1st , 3rd lines, complains missing expression operator, , 2nd line says no coprocess! can shed light on differences between /bin/bash , /bin/sh scripts?
you can use equivalent script in /bin/sh
:
if uname | grep -eq '(qnx|qnx)'; printf "what dev prefix use? " read dev_prefix if echo "$dev_prefix" | grep -eq '^[a-z0-9_-]+@[a-z0-9_-"."]+:'; ... fi fi
Comments
Post a Comment