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.
- 01-24-2004 #1Just 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....
- 01-24-2004 #2Linux 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 <(ls /dir/1) <(ls /dir/2)
- 01-26-2004 #3Just Joined!
- Join Date
- Jan 2004
- Posts
- 2
Thanks
Thanks for everything.....
- 01-28-2004 #4Linux User
- Join Date
- Sep 2003
- Posts
- 254
Hi
Originally Posted by Dolda2000
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
- 01-28-2004 #5Linux 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
- 01-28-2004 #6Linux 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.


Reply With Quote
