Find command error having space in filename

Hi,

I am working in solaris.I am using below script to copy the files from /usr/tmp to /usr/gm
But while running this it is not considering the files list after the filename having space in them.

Example:-
compile_custom_pll.sh
conv_data_sqlload.sh
conv_sqlload.sh
Copy of compile_custom_pll.sh=>From here below files are notconsidered
Copy of conv_data_sqlload.sh
Copy of conv_sqlload.sh
long_XXCUS_INV_Item_STG.ctl
pb_load.sh
smc_extra_items.sh

 
/usr/xpg4/bin/find /usr/tmp -type f -name "*.fmt" -o -name "*.sh" -o -name "*.ctl" | while read filename
  
do
  
echo "Copying $filename to /usr/gm" 
      
cp -f $filename /usr/gm  
if [ $? != 0 ];then
 echo "$filename could not copied to $dest !!!!!!!"
 exit 7
fi
done

Could you please help me how to do this using solaris

Put double quotes aroud filename

cp -f "$filename" /usr/gm  

Hi,

I am searching the ISC_DEPOT_RO_INIT in the files present in /usr/tmp but it is failing when the file have space in their name.For example here i have a file "hello Kevin"

Please suggest what changes i should do here.

/usr/tmp/Sql/APWUPDST.sql:0
/usr/tmp/sanj.test:1
grep: can't open "/usr/tmp/hello"
grep: can't open "Kevin"

 
/usr/xpg4/bin/grep -ixlc "ISC_DEPOT_RO_INIT" `/usr/xpg4/bin/find "/usr/tmp" -type f`

Do the simpler way :wink:

/usr/xpg4/bin/find /usr/tmp -type f -name "*.fmt" -o -name "*.sh" -o -name "*.ctl" -exec cp -f {} /usr/gm/ \;

I am not copying ..i am doing grep here...

 
/usr/xpg4/bin/grep -ixlc "ISC_DEPOT_RO_INIT" `/usr/xpg4/bin/find "/usr/tmp" -type f`

The first post did say that you had issues with copying files with spaces in their names. :frowning: