% is used to remove smallest suffix pattern. Like:
$ gatesfile=/home/gates/bin/foo.barOf course you can append something to the end and forge the functionality of replace:
$ echo ${gatesfile%.bar}
/home/gates/bin/foo
$ echo ${gatesfile%.bar}.x%% is to remove largest suffix pattern:
/home/gates/bin/foo.x
$ gatesfile=posix/src/std# is used to remove smallest prefix pattern, and ## is to remove largest prefix pattern
$ echo ${gatesfile%%/*}
posix
In summary, given:
a=/a/b/c/d
b=b.xxx
+------------------------------------+
|csh bash result |
+------------------------------------+
|$a:h ${a%/*} /a/b/c |
|$a:t ${a##*/} d |
|$b:r ${b%.*} b |
|$b:e ${b##*.} xxx |
+------------------------------------+
No comments:
Post a Comment