Solved

Copy files with different names

Posted on 2006-11-01
1
274 Views
Last Modified: 2010-04-21
I’m trying to copy files from directory “dirA” to another directory “dirB”.  In dirA I have a number of files which have same names but different extensions:
-      opt0000.wav
-      opt0000.gsm
-      opt0000.txt
There aren’t always three files, sometimes there is only wav and gsm, sometimes there is only gsm and txt and so on, so the only constant I can rely on is the name “opt0000”.

Now, I’m trying to copy these files to dirB, however, the problem is that I need to be able to change the name from opt0000 to, for example, opt0020, so I can’t use “cp dirA/opt0000* dirB/.”.

Is there a command that can do something like this?

Thanks,
Kate
0
Comment
Question by:kasiencja
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 17854321
perl -e '$x=$_,s#dirA/opt0000#dirB/opt0020#,system"cp $x $_" for <dirA/opt0000*>'
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

726 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