[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]


    Search the Q&A Archives


I am using a Bash shell, Trying to copy all found...

<< Back to: [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.36)

Question by k0300983
Submitted on 12/3/2003
Related FAQ: [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.36)
Rating: Not yet rated Rate this question: Vote
I am using a Bash shell,

Trying to copy all found readme.txt file in the system to a single ./directory
Can some body say how to do that in a single command line?



Answer by Evan "JabberWokky" E.
Submitted on 5/24/2004
Rating: Not yet rated Rate this answer: Vote
Assuming you have the (very common) find-utils, you can simply:

cp $( locate readme.txt |grep -i '/readme.txt$' ) ./directory

The -i matches ReadMe.txt README.TXT readme.txt and all other variants.  This will fail if the directory contains spaces.  Fixing that is an excercise left to the reader.  (Hint: use a for loop or man find and read the exec flag).

 

Answer by Knight of St John of the Cross
Submitted on 10/8/2006
Rating: Not yet rated Rate this answer: Vote
Can you please first define a naming scheme for the readmes when they are dumped in that one directory?  Perfectly sensible naming schemes exist but copying 1000 files to ./directory/readme.txt is silly.  What do you want ./directory/readme.txt to contain? The concatenation of all those files?

 

Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.


Your name or nickname:
If you'd like to create a new account or access your existing account, put in your password here:
Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

 

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

 

<< Back to: [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.36)


[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]

© 2008 FAQS.ORG. All rights reserved.