I have a simple question about using variables as inputs to a command in a Bash script. I would like to write a script that automatically copies certain contents of a directory, foo, to an embedded computer connected over ssh in another directory, bar.
In other words, I want to turn the following command into an easier to maintain script:
ssh -r /foo/{file1,file2,dir1,*.h,*.hpp,*.c,*.cpp} [email protected]:~/bar
So far, I have the following:
#!/bin/bash
SOURCE='/foo';
FILES='{file1,file2,dir1,*.h,*.hpp,*.c,*.cpp}';
DESTINATION='[email protected]:~/bar';
set -x
scp -r $SOURCE/$FILES $DESTINATION
set +x
However, this gets executed as:
ssh -r '/foo/{file1,file2,dir1,*.h,*.hpp,*.c,*.cpp}' '[email protected]:~/bar'
I'm sure I am using the wrong kinds of quotes or parenthesis somewhere, but I feel like I've tried everything. Thanks to anyone who can help a newbie out. :)