?
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
?
222 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

Bringing Advanced Authentication to the SMB Market

WatchGuard announces the acquisition of advanced authentication provider, Datablink, with one mission – to bring secure authentication to SMB, mid-market, and distributed enterprises with a cloud-based solution, ideal for resale via their established channel & MSSP community.

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Six Sigma Control Plans
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…
Suggested Courses

762 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