Remove last argument from argument list of shell script (bash)

后端 未结 3 724
伪装坚强ぢ
伪装坚强ぢ 2020-12-24 13:47

This question concerns a bash script that is run in automator osx. I am using automator actions to get and filter a bunch of file references from the finder. Then I append t

3条回答
  •  时光说笑
    2020-12-24 14:13

    You can also get all but the last argument with

    "${@:0:$#}"
    

    which, honestly, is a little sketchy, since it seems to be (ab)using the fact that arguments are numbered starting with 1, not 0.

    Update: This only works due to a bug (fixed in 4.1.2 at the latest) in handling $@. It works in version 3.2.

提交回复
热议问题