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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -