LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-04-2015, 07:34 AM   #1
bravored
Member
 
Registered: Mar 2005
Distribution: RHEL, freeBSD, Solaris
Posts: 49

Rep: Reputation: 0
Wildcard Transfer Files


Hey Guys/Gals,

I need transfer the latest file from nested folders to its new directory.

i.e *.conf (there are other files in here alone with 1-10 conf - 10 being latest per todays date)

i.e cp $MYHome/source.bak/0001/pl1/10.conf $MYHome/NEWsource/0001/pl1/
cp $MYHome/source.bak/0013/pl1/2.conf $MYHome/NEWsource/0013/pl1/


....commonality is $MYHome/source.bak , $MYHome/NEWsource/
and 0001-0016, and the pl1

Any ideas?
 
Old 12-04-2015, 10:20 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Code:
cd $myhome/source.bak
find 000[1-9]/pl1 001[1-6]/pl1 -name '*.conf' | cpio -pd $myhome/newsource
Some tuning required.
And I am sure there are better/nicer/faster ways.

What this does:
  • List all the files with the required name, including their paths relative to source.bak
  • Copy them to newsource, paths included
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving files with wildcard - mv -r doesn't work and cp keeps original copy.. cilbuper Linux - General 6 12-10-2015 04:18 AM
run grep only on certain files using wildcard threezerous Linux - Newbie 4 12-21-2011 12:54 PM
copy wildcard files from directories to matching ones in another dir akufoo Linux - Newbie 1 02-11-2011 11:56 PM
using curl to DL files from HTTP sites with wildcard dehuszar Programming 7 09-03-2009 04:52 AM
how to unzip all files with a wildcard path? adamrosspayne Linux - Newbie 12 06-20-2006 01:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration