Find the answer to your Linux question:
Results 1 to 4 of 4
Trying to do a diff to find files present in 1 directory but not in the other. But, diff not only gives files present in 1 directory and not in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2004
    Posts
    5

    diff option. getting only selected files


    Trying to do a diff to find files present in 1 directory but not in the other.

    But, diff not only gives files present in 1 directory and not in other, but also those present in second one but not in the first one.
    I want to avoid that.

    How can I only get those that are present in directory 1 and not in the other?

    Tried the unidirectional option, but that outputs the content of the file.

    am i doing something wrong?

  2. #2
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    Try this:

    Code:
    ls -1 /pathto/dir1/ > ./dir1
    ls -1 /pathto/dir2 > ./dir2
    diff ./dir1 ./dir2 >> ./diff-list
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  3. #3
    Just Joined!
    Join Date
    Dec 2004
    Posts
    5
    how do i do the same recursively..??
    this one worked for flat directories..

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    You'll have to use the -R switch to ls. Check out 'man ls' for more fun with ls.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •