Artificial intelligent assistant

what does "serial=${serial##*.}" do? > **Possible Duplicate:** > How do ${0## _/} and ${0%/_ } work? 0:root@SERVER:/ # 0:root@SERVER:/ # serial=$(lscfg -vl hdisk1 | awk '/Serial Number/') 0:root@SERVER:/ # echo $serial Serial Number...............11BBGG11235 0:root@SERVER:/ # 0:root@SERVER:/ # 0:root@SERVER:/ # serial=${serial##*.} 0:root@SERVER:/ # echo $serial 11BBGG11235 0:root@SERVER:/ # What does exaclty serial=${serial##*.} do? Can someone please explain it? It's hard to google it :D

Its a parameter expansion in shell. For example:

serial=${serial##*.} -- this will get the value in the last field delimited by '.' seperator. Grab the most last '.' in the value and print the rest of the data.


parameter result
----------- ------------------------------
${NAME} polish.ostrich.racing.champion
${NAME#*.} ostrich.racing.champion
${NAME##*.} champion
${NAME%%.*} polish
${NAME%.*} polish.ostrich.racing



parameter result
----------- --------------------------------------------------------
${FILE} /usr/share/java-1.4.2-sun/demo/applets/Clock/Clock.class
${FILE#*/} usr/share/java-1.4.2-sun/demo/applets/Clock/Clock.class
${FILE##*/} Clock.class
${FILE%%/*}
${FILE%/*} /usr/share/java-1.4.2-sun/demo/applets/Clock


For more examples look at <

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 48008553a0d990349204d063d96b0dd8