How to create dummy files in UNIX?

sventhan
sventhan used Ask the Experts™
on
hello experts -

How to create the dummy files for last 6 months in UNIX?
I need these dummy files for testing a archiving script that we have.

Any ideas?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT-specialist
Commented:
make an empty file
vi file200903
:wq!

or

a file with 1 record
echo testfile > file200903

cp file200903 file200904
etc

Author

Commented:
Thanks flow@.
The key here is the timestamp. The archiving script will be looking for this unix system timestamp as a key to archive the files which are older then 180 days.
 
 

Author

Commented:
Thanks.

found a soultion by myself.
Most Valuable Expert 2013
Top Expert 2013

Commented:
The proposed solution above will create files with the current timestamp.

To create files with a certain timestamp you should have been using

touch -t [[CC]YY]MMDDhhmm[.SS] filename

with
 
CC - century e.g. '20'
YY - year e.g.'09'
MM - month e.g. '04'
DD - day e.g. '01'
hh - hour e.g.'00'
mm - minute e.g. '00'
SS - second e.g. '00'

So touch -t 200904010000 filename will create a file of name filename older than 6 months, i.e. from  April, 1st 2009

Always glad to help,

wmp

Author

Commented:
Thanks wmp for the wonderful answer.  Good luck to you.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial