I've been trying to get this working for a bit now... this question has helped, but I'm still struggling to get this to work. I'd prefer not to install homebrew, because this is a rare task that I'm performing right now.
I have a couple thousand files with a string of text, an underscore, more text, underscore and finally the important file name that I want to preserve. Dropping the first *_*_
and preserving the last part, with file extension, is attempted with \(*\)/\1/
.
I've tried a couple different things and all I've got is the original filenames being spit out again. Any help is appreciated. - not sure if it's a regex issue, or sed, or probably a little of both.
ls | sed 's/^*_*_\(*\)/\1/' > ouput.txt;
ls | sed 's/^*_*_\(*\$\)/\1/' > out.txt
ls | sed 's/\(^*_*_\)\(*\$\)/\2/' > out.txt
ls | sed 's/\(^.*_+.*_+\)\(.*\$\)/mv & \2/' > out.txt