Register
Results 1 to 2 of 2

Thread: File change

  1. #1
    Newbie
    Join Date
    Jul 2011
    Posts
    1
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts

    Default File change

    I am looking to swap out about 30 images in some folders on a RedHat linux box. The same dozen images appear in a LARGE number of folders (bad planning, i know, but i am inheriting this mess). Does anyone know of a way to swap out complete files quickly (by large number of folders, i am talking thousands)

  2. #2
    V.I.P. Member
    GastonJ's Avatar
    Join Date
    Dec 2009
    Posts
    5,505
    Thanks Thanks Given 
    836
    Thanks Thanks Received 
    1,676
    Thanked in
    1,083 Posts

    Default

    Try looking up use of the 'find' command, it's flexible and allows interaction, such as

    find / -name "myfile.txt" -exec rm -f {} ";"

    will recurse all subdirectories of the root '/' directory and delete all instances of myfile.txt

    Depends what you want to do. What you have described so far isn't very descriptive. However if I wanted to copy a new file of the same name into all subdirectories of the one I was in I'd use:

    find ./ -name "myfile.jpg" -exec cp /home/gastonj/myfile.jpg {} ";"

    However I have not tested it, so check it first if that's the sort of thing you're after..

    HTH
    Last edited by GastonJ; 20th August, 2011 at 11:34 PM.
    My master plan is to live forever..... going to plan so far
    Despite the cost of living, it's still very popular.
    No good deed goes unpunished....


 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.