How do I use a variable argument number in a bash script?

后端 未结 3 1810
渐次进展
渐次进展 2020-12-31 06:52
#!/bin/bash
# Script to output the total size of requested filetype recursively

# Error out if no file types were provided
if [ $# -lt 1 ]
then 
  echo \"Syntax Err         


        
3条回答
  •  再見小時候
    2020-12-31 07:11

    if you don't want to include the first one, the way to do that is to use shift. Or you can try this. imagine variable s is your arguments passed in.

    $ s="one two three"
    $ echo ${s#* }
    two three
    

    Of course, this assume you won't be passing in strings that is one word by itself.

提交回复
热议问题