Unix command to move files for certain pattern

Hi expert


Under unix, what command I can use to move a list of file to a certain name

For example

files contains character "abc"

mv XXXabcXXX to XXXXXX (remove the "abc" of the file name)

4eyesgirlAsked:
Who is Participating?
 
ahoffmannCommented:
# not as nice as perl, but just standard unix:
ls *abc* | sed -e 's#\(.*\)abc\(.*\)#mv & \1\2#'|sh

# for testing, just omit the final |sh
0
 
ozoCommented:
perl -e 'for( <*abc*> ){ ($to=$_)=~s/abc//; rename $_,$to or warn "$_, $to $!" }'
0
 
4eyesgirlAuthor Commented:
Can you explain to me what this does?  I don't know Perl that well

Thanks
0
 
4eyesgirlAuthor Commented:
Thanks ahoffman and ozo, both solutions work!!! so I split the point equally.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.