Solved

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

Posted on 2011-09-02
2
220 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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

696 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