#1
  1. No Profile Picture
    Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    13
    Rep 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!
  2. #2
  3. No Profile Picture
    Cypher
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Location
    La Jolla, CA
    Posts
    121
    Rep Power
    14
    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
  4. #3
  5. Perl Jedi
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Location
    New Hampshire
    Posts
    116
    Rep Power
    0
    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
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Location
    Pacific NW, USA
    Posts
    27
    Rep Power
    0
    I think you can use the unix command rsync
    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.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    2
    Rep Power
    0
    hi did you find the code for identical files?

IMN logo majestic logo threadwatch logo seochat tools logo