UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 13th, 2004, 07:56 PM
007spy 007spy is offline
Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 13 007spy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
shell-programming HELP!!!

write a shell script that will scan the files in 2 directories,finding identical files and replacing them by "hard" link to a single copy. "identical" means
same size, same content, same ownership(UID & GID) and same permission. If two same files have different timestamps, use the oldest as the original to copy and we only check the "ordinary" files in the first level of the directory. The script will take 2 command line arguments which are the names of the two directories to check.

My idea is to
using ls command to display a directory and store the contents in a file named "file1";
So do for the second directory, and name "file2";
compare "file1" and "file2" using cmp or diff command;

However how can I find all identical files from the compared result? Please help me, thanks a lot!

Reply With Quote
  #2  
Old March 15th, 2004, 01:19 AM
eworley eworley is offline
Cypher
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: La Jolla, CA
Posts: 121 eworley User rank is Lance Corporal (50 - 100 Reputation Level)eworley User rank is Lance Corporal (50 - 100 Reputation Level)eworley User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 57 m 6 sec
Reputation Power: 5
It is clear from this post, and from your post in the C/C++/C-Obj section that you are trying to get someone to write code for you. It is also clear that you are only giving us a small amount of information that is most likely straight off of a handout that you got in school.

Good luck, you will need it.

-Evan

Reply With Quote
  #3  
Old March 15th, 2004, 07:09 AM
jlk's Avatar
jlk jlk is offline
Perl Jedi
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: New Hampshire
Posts: 108 jlk User rank is Sergeant (500 - 2000 Reputation Level)jlk User rank is Sergeant (500 - 2000 Reputation Level)jlk User rank is Sergeant (500 - 2000 Reputation Level)jlk User rank is Sergeant (500 - 2000 Reputation Level)jlk User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 10 h 41 m 53 sec
Reputation Power: 15
Quote:
Originally Posted by eworley
It is clear from this post, and from your post in the C/C++/C-Obj section that you are trying to get someone to write code for you. It is also clear that you are only giving us a small amount of information that is most likely straight off of a handout that you got in school.

Good luck, you will need it.

-Evan


<sniff sniff>.......smell that.........<sniff sniff>............it smells like........<sniff sniff>.........AH, Yes.... HOMEWORK!!!

(Not to mention his same post in the Linux forum as well.

jlk

Reply With Quote
  #4  
Old May 4th, 2004, 01:17 AM
NPRao NPRao is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Pacific NW, USA
Posts: 26 NPRao User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 35 m 46 sec
Reputation Power: 0
Send a message via AIM to NPRao
I think you can use the unix command rsync
Quote:
rsync rsync
NAME
rsync - faster, flexible replacement for rcp

SYNOPSIS
rsync [OPTION]... SRC [SRC]... [USER@]HOSTEST

rsync [OPTION]... [USER@]HOST:SRC DEST

rsync [OPTION]... SRC [SRC]... DEST

rsync [OPTION]... [USER@]HOST::SRC [DEST]

rsync [OPTION]... SRC [SRC]... [USER@]HOST:EST

rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]

rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST

DESCRIPTION
rsync is a program that behaves in much the same way that rcp does,
but has many more options and uses the rsync remote-update protocol to
greatly speed up file transfers when the destination file already
exists.

The rsync remote-update protocol allows rsync to transfer just the
differences between two sets of files across the network link, using
an efficient checksum-search algorithm described in the technical
report that accompanies this package.

Some of the additional features of rsync are:

o support for copying links, devices, owners, groups and
permissions

o exclude and exclude-from options similar to GNU tar

o a CVS exclude mode for ignoring the same files that CVS would
ignore

o can use any transparent remote shell, including rsh or ssh

o does not require root privileges

o pipelining of file transfers to minimize latency costs

o support for anonymous or authenticated rsync servers (ideal for
mirroring)

GENERAL
There are eight different ways of using rsync. They are:

rsync
o for copying local files. This is invoked when neither source nor
destination path contains a : separator
o for copying from the local machine to a remote machine using a
remote shell program as the transport (such as rsh or ssh). This
is invoked when the destination path contains a single :
separator.
o for copying from a remote machine to the local machine using a
remote shell program. This is invoked when the source contains a
: separator.
o for copying from a remote rsync server to the local machine. This
is invoked when the source path contains a :: separator or a
rsync:// URL.
o for copying from the local machine to a remote rsync server. This
is invoked when the destination path contains a :: separator or a
rsync:// URL.
o for copying from a remote machine using a remote shell program as
the transport, using rsync server on the remote machine. This is
invoked when the source path contains a :: separator and the --
rsh=COMMAND (aka "-e COMMAND") option is also provided.
o for copying from the local machine to a remote machine using a
remote shell program as the transport, using rsync server on the
remote machine. This is invoked when the destination path
contains a :: separator and the --rsh=COMMMAND option is also
provided.
o for listing files on a remote machine. This is done the same way
as rsync transfers except that you leave off the local
destination.

Reply With Quote
  #5  
Old July 10th, 2004, 11:49 PM
visual61 visual61 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 2 visual61 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi did you find the code for identical files?

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > shell-programming HELP!!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway