Skip to main content

Can't store multiple arguments with read -p in macOS terminal using bash [Resolved]

I am trying to store words from an input as parameters with read -p as follows :

    read -p "Enter your command: " cmd arg1 arg2
    echo "$cmd"
    echo "$arg1"
    echo "$arg2"

With this, $cmd contains all 3 inputs separated by spaces, $arg1 and $arg2 are empty. Any idea why?


Question Credit: Nawra C
Question Reference
Asked May 15, 2019
Posted Under: Apple
4 views
1 Answers

Your Answer