1827885 Members
1453 Online
109969 Solutions
New Discussion

Automated file creation

 
SOLVED
Go to solution
pmcwill
Occasional Contributor

Automated file creation

Can anyone help with my query?

A host system is dependant on receiving an FTP of a file, but some days my system isn't used and therefore the file isn't created. I'm told I need to have a blank file ready to FTP if the system isn't used that day.

I need to do a find in a directory for files with .xmt extension and if the file doesn't exist i need to create a blank one.

Can anyone suggest a script to use, i'll then add it to the cron to run automatically
3 REPLIES 3
Richard Hepworth
Esteemed Contributor
Solution

Re: Automated file creation

just use touch /filename. If the file already exists it will just have it's modification time updated, if it doesn't exist it will be created
James R. Ferguson
Acclaimed Contributor

Re: Automated file creation

Hi:

Why not something as simple as:

# FILE=/var/tmp/somefile;[ -f ${FILE} ] || touch ${FILE}

Regards!

...JRF...
Ganesan R
Honored Contributor

Re: Automated file creation

ls //*.xmt 2> /dev/null
if [ $? -ne 0 ];then
touch filename.xmt
fi
Best wishes,

Ganesh.