Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm not to good at writing regular

Status
Not open for further replies.

jmdc

MIS
Feb 2, 2001
19
US
I'm not to good at writing regular expressions so if someone could help me I would really appreciate it. Basically I have bunch a files in a directory that look like the this "clog_b43.jus11_07172002_00.ab.err". I want to get rid of everthing but "07172002_00.ab.err". How can I write a regular expression to do this. I'm actually trying to find the answer in the regualre expression book by O'Reilly.
 
@files= grep/.err/,readdir(DIR) or die "Unable to read directory $srcdir: $!\n";

This is a line in my script that I use to put everything with a .err extension into an array.
 
Part of writing a regular expression involves finding a pattern that is common among all the files that will give you the result that you want. That is not possible given only one example filename. When you say that the filenames are like
Code:
clog_b43.jus11_07172002_00.ab.err
how are the other files like this one?
For example, to get [tt]07172002_00.ab.err[/tt], do you want to keep everything after the second undersocre from the left or after the first underscore after the first period, or keep 'numbers-underscore-numbers-period-letters-period-err'?
Get the idea? Could you post a few more example files or better describe the part of the filename that you want to keep?

jaa
 
Another script someone else wrote tries to send some file to another server via a home grown protocal every hour. If for some reason the other server was unable to receive this information it will create an error file like the ones below. What my script is doing now is opening a dir and reading the contents of the dir, then puts the info into an array. What I want to do is have my script run every hour and check to see if the one file has failed more than once.

clog_b43.jus11_07172002_00.ab.err - failed once
clog_b43.jus11_07172002_01.ab.err - failed a second time
clog_b43.jus11_07182002_00.ab.err
clog_b43.jus11_07182002_04.ab.err

This is telling me

clog_b43.jus11_ - example machine name
07 - is the month
17 - is the 17th day
2002 - is the year
00 - is the hour
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top