In an ash/dash function, I can refer to the full parameter list like this:
allparameters() { echo "$@"; }
Which gives me:
$ allparameters yyyyy abffcd efgh
yyyyy abffcd efgh
I want to skip yyyyy
, so I tried ${@:2}
:
butlast() { echo "${@:2}"; }
However, this skips the first two characters:
$ butlast yyyyy abffcd efgh
yyy abffcd efgh
$ butlast abffcd efgh
ffcd efgh
I wasn't able to find the colon syntax in the man page for ash, so that may be a bash-ism. What is the equivalent?
${name:offset}
is a bash
ism, but you can use the POSIX shift
command for what you want.
$ butlast() { shift; echo "$@"; }
$ butlast foo bar baz
bar baz
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.