Linux cp with a regexp
问题 I would like to copy some files in a directory, renaming the files but conserving extension. Is this possible with a simple cp , using regex ? For example : cp ^myfile\.(.*) mydir/newname.$1 So I could copy the file conserving the extension but renaming it. Is there a way to get matched elements in the cp regex to use it in the command ? If not, I'll do a perl script I think, or if you have another way... Thanks 回答1: Suppose you have myfile.a , myfile.b , myfile.c : for i in myfile.*; do echo