LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-11-2011, 11:56 AM   #1
SydPersia
LQ Newbie
 
Registered: Feb 2011
Posts: 7

Rep: Reputation: 0
Red face Synchronize two directories (bash script)


hello guys ..
I really do not know how I do this year ..

if you can help me?

is very important ..

thanks..

It achieves a bash script that takes two parameters (command line). These two parameters must be two paths of two directories (existing, and different such as not being of the other sub-folder). Path1 and path2 are for simplicity.
The script will recursively visit the two directories and all sub-directories, sub-sub-directories, etc.. Looking for differences between their contents (files or directories). In particular, suppose that we work with both path1 and path2 directory, and scanned the files contained therein. These situations can occur:

* Path1 exists in a file that is not present in path2: in this case, the script displays the path of the file to you (print screen) and asks if he wants the file is copied in path2 or not. Reads the user's response and acts accordingly.
* Path2 exists in a file that is not present in path1: in this case, the script displays the path of the file and asks if the user wants the file is copied in path1 or not. Reads the user's response and acts accordingly.
* Both path1 path2 in a file with the same name but different contents: in this case, the script displays the path of the two files (which of course will start with path1 and path2 but end with an equal) to the user together with the two dates have been changed last time. Then asks if you want the file to be replaced by one in path1 path2, or that the file is replaced by one in path2 path1, or that both are left unchanged. Reads the user's response and acts accordingly.
* Both path1 path2 in a file with the same name and same content, in which case the script does nothing and proceeds with the next file.

This is done for all regular files in path1 and path2. The special file (socket, device, symbolic link ...) are ignored. For folders in path1 and path2 is recursively by:

* Path1 if there is a folder that is not present in path2: in this case, the script displays the path to the folder and asks if you want the folder and all its contents are copied to path2. Reads the user's response and acts accordingly.
* Path1 if there is a folder that is not present in path2: similar at first.
* Both path1 path2 that there are two folders with the same name as the script works recursively on the two folders.
 
Old 02-11-2011, 01:33 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Dude, we aren't here to do your work for you. This appears to be a coursework assignment pasted verbatim. Please don't use these forums as a substitute for learning. If you have *specific* problems then please ask *specific* questions.
 
Old 02-11-2011, 05:20 PM   #3
SydPersia
LQ Newbie
 
Registered: Feb 2011
Posts: 7

Original Poster
Rep: Reputation: 0
hello chris ..!

but I just wanted a little help ..
because I am confused ..
thanks anyway.
 
  


Reply



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
BASH script that removes sub-directories (not just files) but keeps the two newest. kennc Linux - Newbie 2 04-23-2009 01:09 PM
Bash script to search through directories. mcdrr Programming 5 05-11-2007 05:41 PM
synchronize contents two files with a bash script paul_mat Linux - Software 5 01-17-2007 06:31 AM
bash: make rename script traverse directories morrolan Programming 2 11-08-2006 10:52 AM
Bash script about directories tarja Programming 3 11-23-2005 01:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:15 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