Solved

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

Posted on 2011-09-02
2
212 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
2 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 500 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
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…
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now