number of tokens in bash variable

前端 未结 7 2166
挽巷
挽巷 2020-12-09 08:41

how can I know the number of tokens in a bash variable (whitespace-separated tokens) - or at least, wether it is one or there are more.

7条回答
  •  轮回少年
    2020-12-09 09:05

    Not sure if this is exactly what you meant but:

    $# = Number of arguments passed to the bash script

    Otherwise you might be looking for something like man wc

提交回复
热议问题