Solved

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

Posted on 2011-09-02
2
207 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
Comment Utility
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
Comment Utility
Works great!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
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…

744 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

18 Experts available now in Live!

Get 1:1 Help Now