Need help with sed or awk and regular expressions
inode0
inode0 at gmail.com
Sat Jul 2 03:09:03 UTC 2005
On 7/1/05, Michael Ault <mikerault at yahoo.com> 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
>
> ...
>
> Regular expressions make my head hurt...anyone got a
> quick solution?
Hi Mike,
Does it need to be sed or awk? Perhaps you could avoid headaches by
just using cut a couple of times?
$ echo $(echo 44.MR3M01J.AF_TBL_COL_1.2005-06-30.DAT | cut -f0-3 -d_ |
cut -f3 -d.).DAT
AF_TBL_COL.DAT
Or if you have the string in a shell variable in bash you can make the
transformation like this if you have extglob on.
$ echo $FOO
44.MR3M01J.AF_TBL_COL_1.2005-06-30.DAT
$ echo ${FOO//+(44.MR3M01J.|_[12]*[0-9-])}
AF_TBL_COL.DAT
John
More information about the Redhat-install-list
mailing list