[vox-tech] Regular expression help

David Spencer, Internet Handyman spencer at pageweavers.com
Wed Jun 30 15:01:13 PDT 2010


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??

Thanks again,


-- Dave Spencer, PageWeavers


More information about the vox-tech mailing list