# Need help with Scripting diff command

**URL:** <https://community.unix.com/t/need-help-with-scripting-diff-command/183169>\
**Category:** Shell Programming and Scripting\
**Created:** [January 25, 2008, 4:12pm UTC](https://community.unix.com/t/need-help-with-scripting-diff-command/183169 "2008-01-25T16:12:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tlfletcher05](https://community.unix.com/letter_avatar/tlfletcher05/32/6_449c533f586939b6e5f246632a46421f.png) [@tlfletcher05](https://community.unix.com/u/tlfletcher05)\
**Post date:** [January 25, 2008, 4:12pm UTC](https://community.unix.com/t/need-help-with-scripting-diff-command/183169/1 "2008-01-25T16:12:39Z")

</div>

Here is where I am at so far.....  
-------------------------  
#!/bin/bash  
echo "Enter the output file name"  
read output\_file  
echo "Enter the Orginal file Name"  
read write\_file  
d= ' diff $write\_file $output\_file '  
if $d = 1 ;then  
echo "files are not identical"  
else  
echo "they areidential"  
fi  
-------------------

I am not sure what I am doing wrong, and I am new at this  
so it could be something small..

---

<div class="post-metadata">

**Author:** ![joeyg](https://community.unix.com/user_avatar/community.unix.com/joeyg/32/780_2.png) [@joeyg](https://community.unix.com/u/joeyg)\
**Post date:** [January 25, 2008, 5:01pm UTC](https://community.unix.com/t/need-help-with-scripting-diff-command/183169/2 "2008-01-25T17:01:42Z")

</div>

Perhaps try

d=$(diff $write\_file $output\_file)

not sure about your d=1 logic ??  
I think you want to see if d is blank or has something in it.  
Perhaps the difference in files is a '1'

---

<div class="post-metadata">

**Author:** ![zouhair](https://community.unix.com/letter_avatar/zouhair/32/6_449c533f586939b6e5f246632a46421f.png) [@zouhair](https://community.unix.com/u/zouhair)\
**Post date:** [January 26, 2008, 1:19am UTC](https://community.unix.com/t/need-help-with-scripting-diff-command/183169/3 "2008-01-26T01:19:05Z")

</div>

Maybe you want only to get the "$?" result for that matter:

#!/bin/bash  
echo "Enter the output file name"  
read output\_file  
echo "Enter the Orginal file Name"  
read write\_file  
diff $write\_file $output\_file \> /dev/null  
if [$? = 0];then  
echo "files are identical"  
else  
echo "they are not identical"  
fi
