can anyone tell me how to search and copy files under unix?
im writing shell scripts with 'vi' and 'pico'
something like
read directoryName
if [ $directoryName contains any *.src files ]
then
echo Copying the files
copy those *.src files to sub1(another directory) using cp
else
echo No files found!
fi
The for statement is essentially the same thing you are trying to do with the IF statement...
you executue a command until the search results run out...
For name in `find ... ... ... ` gives you a loop that will execute the commands after the DO command...the same way that you are trying to do with your IF statement... it is the same thing essentially...
So, when you tuck the "find "command in the for loop, you will get your desired result... Your "found" files will be copied to your destination directory...
For name in `find / -name *src `
do
your command here ... echo blah blah
your command here ... cp $name blah blah
done
You will have to make sure the find command responds wiht the FULL PATH of the file you wish to move or be in the directory you want to search to make it easier to copy it to your $HOME...