raptorred |
08-02-2009 06:01 PM |
Bash Variable Problem
Hi ive been using linux for a while but I am just getting into shell scripting, im currently trying to get a simple script for finding and copying files powered by the command:
Code:
find . -name "*.doc" 2>&1|grep -iv denied|sed "s/\([^A-Za-z0-9]\)/\\\\\1/g"|xargs -ivar cp "var" ~/test
this works fine from the command line but when put in a script such as:
Code:
#!/bin/bash
echo "What would you like to Find?"
read fc1
echo "Where do you want to copy files?"
read fc2
find . -name "$fc1" 2>&1|grep -iv denied|sed "s/\([^A-Za-z0-9]\)/\\\\\1/g"|xargs -ivar cp "var" $fc2
it outputs:
Code:
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
cp: cannot create regular file `~/test': No such file or directory
......
with the keyboard inputs for $fc1 and $fc2 being *.doc and ~/test respectivly. The only problem i can see is the xargs -ivar "var" part possibly needing $var to be defined? Any help appreciated.
|