?
Solved

copy a series of files in a series of directories to another directory using perl or shell

Posted on 2011-09-02
2
Medium Priority
?
223 Views
Last Modified: 2012-05-12
Ok. I have output that creates a new file every 12 hours in a new folder. I simply want to copy a file that has the name hysplit.haw.horiz.so4.2011082612.txt however the file names will have different numbers that correspond to different directories on the same day so the date portion will be different. So I want each file with the file name beginning with hysplit.haw.horiz.so4 and endiing in txt from all directories beginning with /path/results. and after the period . is the date so this will give me one file per day and all the files would be put into this  directory /path2/forecastfiles
0
Comment
Question by:libertyforall2
[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
2 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 36476043
The following will work if you don't have too many directories

cp /path/results*/hysplit.haw.horiz.so4.*.txt /path2/forecastfiles

Open in new window



otherwise do

find /path -name "hysplit.haw.horiz.so4.*.txt" | xargs -i cp {} /path2/forecastfiles

Open in new window

0
 

Author Closing Comment

by:libertyforall2
ID: 36476183
Works great!
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

650 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