[vox-tech] Regular expression help

Chanoch (Ken) Bloom kbloom at gmail.com
Wed Jun 30 16:34:00 PDT 2010


On Wed, 2010-06-30 at 15:01 -0700, David Spencer, Internet Handyman
wrote:
> Guys, I'm sorry about asking this on the list; but I seem to have a mental
> block when it comes to regular expressions. Here's what I'm trying to do:
> 
> I have a lot of directories with a vast number of files, some of which I wish
> to delete based on the month they were created. I've built a file from some
> full directory listings that has all the files I wish to delete. (Just go with
> me on this and don't suggest alternative methods of performing the task - I'm
> simplfying the job so it can be explained more easily.)
> 
> A snippet of the file would look like this:
> 
> -rw-------  1 auser auser 3.7K Apr 12 10:11 auser/folder/new/127109228.file
> -rw-------  1 auser auser  16K Apr 12 12:32 auser/folder/new/127110076.file
> 
> I would like to write either single-line perl command or a nano search and
> replace to substitute the directory info and replace it with a file delete
> so it would look like this:
> 
> rm -f auser/folder/new/127109228.file
> rm -f auser/folder/new/127110076.file
> 
> Then I can just execute converted directory file as a shell script and
> delete my files. But I'm having a brain-freeze on what a valid regex would
> look like to match. Help??

Just use vim's visual block mode to delete the text that's already there
and insert new text.

--Ken


More information about the vox-tech mailing list