How can a command-line argument containing a dot (.) be passed? Are there any escape sequences for capturing characters like dot?
The following invocation of a bash-script from the shell does not work:
# ./deploy.sh input.txt
./deploy.sh: line 9: input.txt: syntax error in expression (error token is ".txt")
I have tried the following:
- backslash
- quote
- double quotes
- ./deploy.sh input (this works)
EDIT
Take this use-case:
- I have 3 files: server.jar client.jar gui.jar
- I need to scp them from a source to a dest
- source dir: login1@host1:/home/xyz/deploy/
- dest dir: login2@host2: /data/apps/env/software/binary/
Solution:
- Read artifacts to be copied into an array from the command-line
- create dest path and source path strings by using the correct directory prefixes
- use a for loop to scp each artifact (having figured out the paths)
Here's the simple script which is doing 1 (read artifacts into an array):
#!/bin/bash
declare -a artifacts
for i
do
artifacts[i]=$i
echo ${artifacts[i]}
done
Execution1
-bash-3.00$ ./simple.sh arg1 arg2 arg3
arg1
arg2
arg3
Execution2
-bash-3.00$ ./simple.sh arg1.txt arg2.txt arg3.txt
./simple.sh: line 7: arg1.txt: syntax error in expression (error token is ".txt")
bash
; this sounds like an issue with your scriptdeploy.sh
and we would need to see it to know what it's doing and how (if at all) to change it.