Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 25th August 2006, 08:36
z3cka z3cka is offline
Junior Member
 
Join Date: Aug 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help writing simple copy script

I have a situation in which i have many directories with one file in each of them. I would like to write a script that would go into each directory and copy the file in that directory one level up.

For example, i would like the *.txt files here:

/startingDirectory/
-->dirA/
------>fileA.txt
-->dirB/
------>fileB.txt

To be copied or moved to yeild:

/startingDirectory/
-->dirA/
-->dirB/
-->fileB.txt
-->fileA.txt

*** the *.txt files can be copied or moved i don't have a preference.

I would like to do this in a linux bash shell. The names of the files should be arbitrary to the scripts. It should be able to just move to each directory recursively.

Thank you in advance, please let me know if i was not specific enough.
Reply With Quote
  #2  
Old 26th August 2006, 06:10
z3cka z3cka is offline
Junior Member
 
Join Date: Aug 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Just an update

I have found some help here: http://forum.cyberciti.biz/post2127.html#2127 including some code.
Please feel free to stop by and see if it helps the thought process a little. I don't mind if you post any solutions here. i will be back, as well as posting the solution here when we figure it out.

Thanks again!

Last edited by z3cka; 26th August 2006 at 06:16.
Reply With Quote
  #3  
Old 26th August 2006, 14:58
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,843
Thanks: 781
Thanked 1,557 Times in 1,476 Posts
Default

As far as I can see from the link, you're close to the solution. Anyway, I recommend to have a look at this guide, it's almost essential if you want to do shell scripting: http://www.tldp.org/LDP/abs/html/index.html
__________________
Falko
--
Follow me on:
Reply With Quote
  #4  
Old 26th August 2006, 23:56
z3cka z3cka is offline
Junior Member
 
Join Date: Aug 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks falko man, i will check out that link.

i appreciate all the good work you put in this forum. keep it up.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help for writing shell script chris_87 Programming/Scripts 7 4th April 2007 16:50
Need some script if possible karabaja Programming/Scripts 4 19th August 2006 16:09
Need help for writing shell script erez Programming/Scripts 4 16th June 2006 15:23
PERL script help... simple issue i think gjcomputer General 3 14th March 2006 10:49
Internal Server Error 500 cgi script mphayesuk General 6 8th February 2006 23:53


All times are GMT +2. The time now is 13:54.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Sponsored Links: Unified Communications: Thoughts, Strategies and Predictions
Join the discussion.
www.seamlessenterprise.com

IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com

Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com

Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com

Red Hat Virtual Experience - a free virtual event. Dec. 9th