Operating System - HP-UX
1752808 Members
5844 Online
108789 Solutions
New Discussion

Re: Check file existence command

 
Dennis Handly
Acclaimed Contributor

Re: Check file existence command

You could use fgrep -f:
fgrep -f file1.txt file2.txt

>Kapil: it should be if [ $? = 0 ]

No, actually it should be: if [ $? -eq 0 ]

>Sagar: Use comm command this is an useful command to compare files.

This only works if the files are sorted.