The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-13-2008
sandiego_coder sandiego_coder is offline
Registered User
 

Join Date: May 2008
Posts: 3
How to parse a string efficiently

I am new to the boards and to shell programming and have a requirement to name new files received with a unique sequence number. I need to look at a particular file pattern that exists and then to increment a sequence by 1 and write the new file.

Example of file names and sequence #

part1_part2_part3_datesequence.dat
or
part1_part2_part3_part4_datesequence.dat

the sequence is a 6 digit right justified 0 filled number attached to the date - 20080501000001.dat, but may be the 4th, 5th, 6th or 7th token of the filename.

I have a script that creates the new files, but I am having trouble with how to efficiently extract the sequence number in order to increment it by 1 for a given file pattern and date and then write the new file.

Any help would be appreciated and I am trying to stay with shell or sed or awk as I do not have access to perl.

thanks!

Mike
Reply With Quote
Forum Sponsor