Watael wrote:
- if you have spaces in $HOME variable, use more quotes
Actually not entirely true. Setting the variable "manually" like this will require quoting:
Code:
#!/bin/bash
# Does not work
var=this is a spaced string
# Works
var="this is a spaced string"
Using read this is not an issue, the input to read is directly put into the variable.
Code:
sajko@hanna:~> cat a.sh
#!/bin/bash
# -p "Input: " will only print "Input: "
read -p "Input: " var
echo "Output: $var"
sajko@hanna:~> bash a.sh
Input: Testing with spaces alot of them ;)
Output: Testing with spaces alot of them ;)
Best regards
Fredrik Eriksson