I want to ask
I have a problem, how do I get input in bash to do newlines?
read -p "List Name: " list
cat <<EOF >names.txt
List Names:
$list
EOF
i can not do a new line or use the command \n , how to add a new line command ?
I want result output names.txt like this
List Name :
Robert
James
Samuel
Best Answer
If you want a list with one item per line, you can use
readarray
:Now you can use
list
as normal array, e.g.${list[1]}
.