Comparing files.

C M Reinehr cmr at amsent.com
Fri Mar 26 09:16:40 PDT 2010


On Fri 26 March 2010 10:31:32 am Ben Duncan wrote:
> I need to write a script compare 2 files (Text based)
> an report back that they are the same or they are different.
>
> diff with -s says they are identical, when they are , but shows
> all the different lines when not.
>
> All I need is to show identical or differnet.
>
> Any ideas or other commands ?
>
> Thanks

Ben,

The version of diff (2.8.1) on my system also has an option:
	-q --brief
		Output only whether files differ.

You could also use the cmp command with the silent option:

	-s --quiet --silent
		Output nothing; yield exit status only

Hope this helps.

cmr


-- 
Debian 'Etch' - Registered Linux User #241964
--------
"More laws, less justice." -- Marcus Tullius Ciceroca, 42 BC



More information about the Linux-users mailing list