Read a variable in bash with a default value

后端 未结 9 658
不思量自难忘°
不思量自难忘° 2020-11-29 16:13

I need to read a value from the terminal in a bash script. I would like to be able to provide a default value that the user can change.

# Please enter your          


        
9条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 17:02

    #Script for calculating various values in MB
    echo "Please enter some input: "
    read input_variable
    echo $input_variable | awk '{ foo = $1 / 1024 / 1024 ; print foo "MB" }'
    

提交回复
热议问题