Strip part from filename

I've many file like this

01-file
01_-_file
01_-_file
01_-_file
01_-_file
01-file

I would remove bold part from filename. Suggestions?Thanks

The sed command gives the command to move the files. The output is piped to sh to execute the command. Check the output first without the coloured part:

sed 's/.*[-_]\(.*\)/mv & \1/' | sh

Regards

Thanks for this quick answer. Can you explain me in detail what sed do in this case?I know sed for is basic function, substitution only. I like to understand this complex command.

To understand the command you must have some basic knowledge of sed, but here we go:

sed 's/.*[-_]\(.*\)/mv & \1/' 

With sed you can save substrings with \(.*\) and recall them back with \1, \2, \3 etc.

Here we saved a portion \(.*\) after the regular expression:

.*[-_]

This regexp means one or more characters ending with a "-" or "" so the saved portion \(.*\) contains the characters after the last "-" or ""

We substitute the string matched by the regular expression with:

mv & \1

& is a character with a special meaning and is replaced with the string matched by the regular expression.

\1 is the recalling of the saved portion \(.*\)

Regards

many many thanks!!