I have the following files:
~/tmp/testbash$ l
file 1.test move.sh*
where move.sh
is:
#!/bin/bash
#-x
FILENAME='file\ .test'
echo $FILENAME
echo joo
mv $FILENAME test.test
When I run ./move.sh
, I get this output and error:
file\ .test
joo
mv: target `test.test' is not a directory
The problem is that it executes the command as:
mv file .test test.test
and not as:
mv file\ .test test.test
How can I fix this?
Variable names cannot contain spaces.
run; The options validvarname=any; tells SAS to allow you to have variable name begin with or contain spaces, special characters or numbers. Additionally, we need to put variable name having spaces in quotes followed by the letter n.
You define a variable name that contains spaces or special characters by writing the name between single quotes (') followed by the character n, for example ' My new Variable'n . Make sure that you use the global SAS-option validvarname=any , before you run your code.
SQL does allow you to "quote" variable names with either [name with space] or with backticks `name with space` . Most other languages do not allow spaces in variable names, because any whitedspace is considered a separator for different lexical unit [different name/word/variable].
If the variable contains embedded spaces, then bracket the variable in double quotes (").
FILENAME='file .test'
mv "$FILENAME" test.test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With