Understanding linux shell script expression -
hi have small script (script name is: test1.sh) looks this
prg=$0 data=`expr $prg : '.*\/.*'` echo $data when run see output as
10
i not understand regular expression written in second line of script. mean?
the expression returns non-zero value if there / within relative filename of script ($0 in sh). if execute script this: sh ../../script.sh, outputs 15, total length of "../../script.sh". matches "../../" '.*\/ , matches script.sh .* part.
Comments
Post a Comment