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

by Nawra C   Last Updated May 15, 2019 19:12 PM

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 ?



Related Questions


Updated September 05, 2018 11:12 AM

Updated September 18, 2017 19:12 PM

Updated December 12, 2018 19:12 PM

Updated April 29, 2019 10:12 AM

Updated May 05, 2019 17:12 PM