Help with replacing a file

Hi

I need to replace A file with B when file A has no contents in linux.

Thanks

What have you tried till now?

I Just created copy.sh
copy.sh

cp /test/serverInfo/nodeManager/NM1/nodemanager.domainsbackup nodemanager.domains

and kept in crontab it runs every 10 mins, but my requirement is when nodemanager.domains get blank i need to replace with nodemanger.domainsbackup file.

thanks

Try this

Use the simple if condition.

 
 
if [ ! -s filename ] ; then
cp file newfile
fi

thanks it works. :slight_smile: