Find the answer to your Linux question:
Results 1 to 6 of 6
Well, i have to write a shell script to accept two argument as input and display differences of files between two directories in "outfile". anyone to help me.......
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2004
    Posts
    2

    need help....


    Well,

    i have to write a shell script to accept two argument as input and display differences of files between two directories in "outfile".

    anyone to help me....

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Don't write a shell script, use the "diff" command instead - that's what diff is for. Diff has several output format options, and personally I find that the one that you get with the -u option is easier to view. To get the difference between two directories, use a command like this:
    Code:
    diff -u <&#40;ls /dir/1&#41; <&#40;ls /dir/2&#41;

  3. #3
    Just Joined!
    Join Date
    Jan 2004
    Posts
    2

    Thanks

    Thanks for everything.....

  4. #4
    Linux User
    Join Date
    Sep 2003
    Posts
    254
    Quote Originally Posted by Dolda2000
    Code:
    diff -u <&#40;ls /dir/1&#41; <&#40;ls /dir/2&#41;
    Hi
    Just a question: we must use the parenthesis and the little < ?
    Coz I use some time diff and I've never seen such a syntax;even in the man page I don't find this.
    Could u explain it plz?
    Thx

  5. #5
    Linux Engineer
    Join Date
    Sep 2003
    Location
    Knoxhell, TN
    Posts
    1,078
    the < is the redirection operator.. it tells the shell to use the output from the following command as the input for the first.. the parentheses tell the shell to execute that command as a whole before redirecting the output.. so 'diff -u < (ls /usr/dir1) < (ls /usr/dir2)'

    says:
    use the result of 'ls /usr/dir1' and the result of 'ls /usr/dir2' as the input for diff -u

    to redirect output somewhere, use > or >> (the double redirection operator means "append to")
    Their code will be beautiful, even if their desks are buried in 3 feet of crap. - esr

  6. #6
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    That's not precisely accurate... While < is a redirection operator, `<(cmd)' is a special construct. It doesn't give the output of the nested command as input to the top-level one. What it does is that it creates a named FIFO (or on Linux I believe it uses /proc/pid/fd or /dev/fd, but that's not important - the semantics are still the same), it connects the output of the nested command to that FIFO and gives the filename of the FIFO to the top-level command. That way, it allows the top-level command to open the FIFO manually.

Posting Permissions

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