LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-29-2014, 04:50 PM   #1
aaronuq
LQ Newbie
 
Registered: May 2014
Posts: 2

Rep: Reputation: Disabled
ask-how to update files with the same name


Hi guys,

I have many small codes which have been used in many different folders. And those codes will get updated at times, so I wondering how can I update them in different folders at the same time instead of going into each folder to check whether there is any code that needs to be updated.

I am thinking that at first I can find all the paths that contain the to-be-updated-codes, and them copy the new codes to those folders. But I don't know how to do this with linux commands, and any better suggestions?

Thank you!

Aaron.
 
Old 05-29-2014, 10:14 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,

not completely sure what you are actually asking, but the command rsync can be used to only copy files if the source file is newer (and different) to the destination file. Eg

Code:
rsync -auv /path/to/source/ /path/to/destination/
will recursively copy files in /path/to/source/ into /path/to/destination/ if the files are missing or older in /path/to/destination/

See the rsync man page and search online for tutorials for more information.

Evo2.
 
1 members found this post helpful.
Old 05-29-2014, 10:20 PM   #3
aaronuq
LQ Newbie
 
Registered: May 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
clarify my question

Quote:
Originally Posted by evo2 View Post
Hi,

not completely sure what you are actually asking, but the command rsync can be used to only copy files if the source file is newer (and different) to the destination file. Eg

Code:
rsync -auv /path/to/source/ /path/to/destination/
will recursively copy files in /path/to/source/ into /path/to/destination/ if the files are missing or older in /path/to/destination/

See the rsync man page and search online for tutorials for more information.

Evo2.
Hi Evo2,

Sorry for my question. Let me clarify it:
For example, if I have a code AAA, which has been used in
~/a1/
~/a2/
~/a3/a4/a5/
...

What I want to do is when AAA has been updated, I also want to update the AAAs in the above folders.
If I used your suggested code or 'cp', the other question is how can I get all the paths containing the code AAA.

Thank you.

Aaron.

Last edited by aaronuq; 05-29-2014 at 10:23 PM. Reason: clarify
 
Old 05-30-2014, 12:05 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,

what do you mean by "a code"? Is this a file? If so you can use soft links. Just put the file in one directory and make the other link to it.

Eg
Code:
mkdir ~/a1/
mkdir ~/a2/
mkdir -p ~/a3/a4/a5/
echo XXX > ~/a1/AAA
ln -s ~/a1/AAA ~/a2/
ln -s ~/a1/AAA ~/a3/a4/a5
Evo2.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
update files in ns2 fualku1986@yahoo.com Linux - Software 5 06-09-2013 03:54 AM
How to update files with svn danndp Linux - Newbie 1 12-13-2010 07:56 PM
cant update some files getasif Linux - Software 2 06-25-2010 01:05 PM
Files update in /etc onlynimal Linux - Security 4 08-29-2007 03:50 AM
How to backup the update files ste85 Linux - Software 3 06-26-2005 10:32 PM


All times are GMT -5. The time now is 06:49 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration