[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Need help with sed or awk and regular expressions



Michael Ault wrote:

I need a sed or awk type command that will convert:

44.MR3M01J.AF_TBL_COL_1.2005-06-30.DAT

to AF_TBL_COL.DAT

the 44.MR3M01J. is always the same, the "_1" could be
both "_1" or "_2", the date varies by month end and
the ".DAT" stays the same.



Try
   sed -n -e 's/44.MR3M01J.\(.*\)_[12]\..*/\1.DAT/' input-file >
output-file

This will also do the same thing:
   sed -n -e 's/[0-9][0-9]\.[0-9A-Z]*\.\([^.]*\)_[12]\..*/\1.DAT/'
input-file > output-file
but will allow the prefix and the suffix of the input to change. Note
that it totally disregards the date in the input string so it can change
also.



Carl.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]