?
Solved

Unix command to move files for certain pattern

Posted on 2006-05-22
4
Medium Priority
?
293 Views
Last Modified: 2011-10-21
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)

0
Comment
Question by:4eyesgirl
  • 2
4 Comments
 
LVL 85

Assisted Solution

by:ozo
ozo earned 1000 total points
ID: 16737434
perl -e 'for( <*abc*> ){ ($to=$_)=~s/abc//; rename $_,$to or warn "$_, $to $!" }'
0
 

Author Comment

by:4eyesgirl
ID: 16737585
Can you explain to me what this does?  I don't know Perl that well

Thanks
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 1000 total points
ID: 16737596
# 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
 

Author Comment

by:4eyesgirl
ID: 16737679
Thanks ahoffman and ozo, both solutions work!!! so I split the point equally.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question