filename_old=filename1235.txt
num=`echo $filename_old | awk -F'filename' '{ print$2 }' | awk -F'.' '{ print$1 }'`
num=$(($num + 1))
newfile=filename$num.txt

On Fri, 3 Aug 2001, Steve Snyder wrote:

> Date: Fri, 3 Aug 2001 00:09:53 -0500
> From: Steve Snyder <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Question for shell script gurus
> 
> I've got a question that I hope one of you Bash shell script gurus can 
> answer: given a filename that contains a number, how does one create a new 
> filename with the number incremented by one?
> 
> An example.  Suppose I have a file with this name:
> 
>     filename1234.txt
> 
> My goal in this case would be to parse this filename such that the number 
> would be extracted then incremented, and a new name, containing the 
> incremented number would be created.  In this case, I would seek to create 
> this filename:
> 
>     filename1235.txt
> 
> Can someone advise me on how this can be done in Bash?
> 
> Thanks.
> 
> 
> 
> _______________________________________________
> Seawolf-list mailing list
> [EMAIL PROTECTED]
> https://listman.redhat.com/mailman/listinfo/seawolf-list
> 

----------------------------------------------------------------
Derek Benson                     |   
Infrastructure Management        | Tel: +61 7 336 53690 
Information Technology Services  | Email: [EMAIL PROTECTED]
The University of Queensland     | http://www.its.uq.edu.au
================================================================



_______________________________________________
Seawolf-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/seawolf-list

Reply via email to