cat file_manipulation.sh
#!/bin/bash
echo -e "source:\n $1";
echo -e "target:\n $2";
echo "files:";
#Convert a String with spaces to array, before delete parenthesis
my_array=(`echo $3 | sed 's/[()]//g'`)
for val in ${my_array[@]}; do
echo " $val";
done
#I add quotes to argument
bash file_manipulation.sh source_dir target_dir "(filename1 filename2)"
you get:
source:
source_dir
target:
target_dir
files:
filename1
filename2
NOTE: it's better without parenthesis
cat file_manipulation.sh
#!/bin/bash
my_array=( $3 )
for val in ${my_array[@]}; do
echo "$val";
done
#I add quotes to argument, and without parenthesis
bash file_manipulation.sh source_dir target_dir "filename1 filename2"
NOTE 2: filenames can't contain whitespace.
$@is already an array and you can use/copy that and/or manipulate it however you like. What are you trying to do exactly?