Need help with Scripting diff command

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help with Scripting diff command
# 1  
Old 01-25-2008
Need help with Scripting diff command

Here is where I am at so far.....
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"
echo "they areidential"

I am not sure what I am doing wrong, and I am new at this
so it could be something small..
# 2  
Old 01-25-2008
formatting the diff command in a script

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'
# 3  
Old 01-26-2008
Maybe you want only to get the "$?" result for that matter:

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"
echo "they are not identical"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with diff command

Platform :Oracle Linux 6.4 Shell : bash In the below sample, although the lines in a.txt and b.txt are jumbled up, there is only one difference : b.txt has an extra line NETHERLANDS $ cat a.txt SPAIN NORTH KOREA PORTUGAL GERMANY SYRIA $ $ $ cat b.txt GERMANY NORTH KOREA SPAIN... (6 Replies)
Discussion started by: John K
6 Replies

2. Shell Programming and Scripting

One-way diff command?

Hello, I am trying to find the different files between multiple directories in Linux, here is a small assumption of what is inside the directories dir1 dir2 dir3 1.txt 1.txt 1.txt 2.txt 3.txt 3.txt 5.txt 4.txt 5.txt 6.txt 7.txt 8.txt I am using the following... (4 Replies)
Discussion started by: Error404
4 Replies

3. Shell Programming and Scripting

serach diff filename in diff location using shell scripting

Hi, I am new to shell scripting. please help me to find out the solution. I need a script where we need to read the text file(consists of all file names) and get the file names one by one and append the date suffix for each file name as 'yyyymmdd' . Then search each file if exists... (1 Reply)
Discussion started by: Lucky123
1 Replies

4. Shell Programming and Scripting

PERL Scripting: Diff 2 files and save output to file3

Hi, I need to create a script to compare 2 files and store the output in a 3rd file. This is how I do manually, but since I need to do this for about 150 files every week, I am trying to automate it using perl. diff -u file1 file2 > file3.patch For my script, - I have 2 files... (4 Replies)
Discussion started by: script2010
4 Replies

5. Shell Programming and Scripting

diff command help

Hi all diff file1 file 2 command will give us op of diff between two file. But it aslo give its position and sign "<" or ">". I dont want position and sign in op. Only diff of content should be come as op. Kindly help me for this. Regards Jaydeep (1 Reply)
Discussion started by: jaydeep_sadaria
1 Replies

6. UNIX for Dummies Questions & Answers

diff command

Is there any option for the diff command (or maybe an entirely different command) that will give you only the text that differs between two files? When I use diff file1 file2, if any text on that line differs from one file to the next it'll print out the entire line. I'd like to see only the text... (2 Replies)
Discussion started by: red baron
2 Replies

7. AIX

diff command

hello i've two files. how i get the diff between the two files to new file. thanks best regards ariec (3 Replies)
Discussion started by: ariec
3 Replies

8. Shell Programming and Scripting

need help in diff command :

i have 2 file named test1,test2 contents of test1: 1 2 3 --------------------------- contents of test2: 1 2 3 4 5 -------------------------------------------------------- my desired o/p should be: diff test2 test1 4 (5 Replies)
Discussion started by: ali560045
5 Replies

9. Shell Programming and Scripting

diff command

All, How to exclude a directory while diff execution? For ex: To exclude file which we don't want to see diff, we have -x <filename>. Thanks in advance (1 Reply)
Discussion started by: Vichu
1 Replies

10. UNIX for Dummies Questions & Answers

shell scripting my own diff command

Hi I would like to run the diff command and recieve a little different output. I am on a linux machine. I am pretty new to shell scripting. So far my idea has shaped up to this, unworking, script. I would like file1: and file2: instead of the usual > or < output you recieve, diff | sed -e ... (4 Replies)
Discussion started by: axcxe
4 Replies
Login or Register to Ask a Question