[Chester LUG] Help with a bash script

Simon Willett simonw at gbitsystems.co.uk
Fri May 16 09:38:12 UTC 2008


Hi Stuart, 

 

A hack would be; 

 

COUNT=`ls RSmmd*001 | wc -w`  

COUNT=`expr $COUNT + 1`

# COUNT now contains the number of files of type RSmmd + 1 

 

But you should really be using date +%Y%m%d you actually do want to pre-zero
the day, and you should also include the year, otherwise the process breaks
come the year end. 

 

 

Hope this helps,

Simon

  _____  

From: chester-bounces at mailman.lug.org.uk
[mailto:chester-bounces at mailman.lug.org.uk] On Behalf Of Stuart Burns
Sent: 15 May 2008 20:38
To: chester
Subject: [Chester LUG] Help with a bash script

 

Hi Everyone.

I need a little help with a batch file. I have managed a bit of it, but i'm
a bit lost now. 

What I need to do is

1.	Looks for file RS000001.001 in folder  
2.	Rename it RSmmdnnn.001 (mm=month, d= day number {Monday=1},
nnnn=unique count for the day)

Now this file can appear up to several times a day (ie its going to run as a
cron job every half hour to pick up the files as they are dumped by ftp) I
can do the basic stuff with the date ie DATE = `date +%m%u` but setting up
the nnnn bit is where  I am getting lost.

Any help appreciated.

Stu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/chester/attachments/20080516/03ca2f5d/attachment.html>


More information about the Chester mailing list