Need help with sed or awk and regular expressions

Carl Reynolds redhat-install-list at hyperbole-software.com
Sat Jul 2 18:13:36 UTC 2005


Michael Ault wrote:

>Excellent, so to pass in a list of file names to be
>converted you would pipe the results of the ls command
>through this? We have a list of about 100 files that
>need to be renamed.
>
>Mike
>
>--- inode0 <inode0 at gmail.com> wrote:
>
>  
>
>>On 7/1/05, inode0 <inode0 at gmail.com> wrote:
>>    
>>
>>>$ echo $FOO
>>>44.MR3M01J.AF_TBL_COL_1.2005-06-30.DAT
>>>$ echo ${FOO//+(44.MR3M01J.|_[12]*[0-9-])}
>>>AF_TBL_COL.DAT
>>>      
>>>
>>Ack! That last hypen is leftover harmless cruft. All
>>one needs is
>>
>>$ echo ${FOO//+(44.MR3M01J.|_[12]*[0-9])}
>>AF_TBL_COL.DAT
>>
>>My first iteration was
>>
>>$ echo ${FOO//+(44.MR3M01J.|_[12].*([0-9-]))}
>>AF_TBL_COL.DAT
>>
>>which may be a more clear expression to match the
>>second part of the
>>string to delete.
>>Regular expressions give just about everyone a
>>headache. :)
>>
>>John
>>
>>_______________________________________________
>>Redhat-install-list mailing list
>>Redhat-install-list at redhat.com
>>
>>    
>>
>https://www.redhat.com/mailman/listinfo/redhat-install-list
>  
>
>>To Unsubscribe Go To ABOVE URL or send a message to:
>>redhat-install-list-request at redhat.com
>>Subject: unsubscribe
>>
>>    
>>
>
>
>Michael R. Ault
>Senior Consultant
>Burleson Oracle Consulting
>770-754-9057
>www.ault.cc
>www.remote-dba.com
>
>_______________________________________________
>Redhat-install-list mailing list
>Redhat-install-list at redhat.com
>https://www.redhat.com/mailman/listinfo/redhat-install-list
>To Unsubscribe Go To ABOVE URL or send a message to:
>redhat-install-list-request at redhat.com
>Subject: unsubscribe
>
>
>
>  
>
As inode0 said, it would probably be safer to do something like
    ls | sed -e 's"44.MR3M01J.\(.*\)_[12]\..*"cp \0 ./temp/\1.DAT"' >
copy-files

then visually inspect the file 'copy-files' before using it. to make
sure it will not create any problems

next
   mkdir temp
   chmod +x copy-files
   ./copy-files

This will copy all the files to the temporary directory that you can
compare with the current directory by counting the number of files in
each and creating lists of the files in each that you can compare
side-by-side to make sure you haven't lost any files before replacing
the current directory with the files in temp.

If you need more help on using Linux tools to make these comparisons,
just ask.



Carl.







More information about the Redhat-install-list mailing list