HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Showing results for 
Search instead for 
Did you mean: 

Automated file creation

Go to solution
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
Richard Hepworth
Esteemed Contributor

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


Why not something as simple as:

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


Ganesan R
Honored Contributor

Re: Automated file creation

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