The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
need help in diff command : ali560045 Shell Programming and Scripting 5 05-26-2008 06:22 AM
diff command Vichu Shell Programming and Scripting 1 04-28-2008 04:06 AM
Need help with Scripting diff command tlfletcher05 Shell Programming and Scripting 2 01-25-2008 11:19 PM
difference between AIX shell scripting and Unix shell scripting. haroonec Shell Programming and Scripting 2 04-12-2006 05:12 AM
diff command gilead29 UNIX for Dummies Questions & Answers 7 03-09-2004 06:12 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-10-2003
Registered User
 

Join Date: Sep 2003
Location: denver
Posts: 3
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 s/^<*/file1:/g s/^>*/file2:/g d/---/g

Can anyone help me shape this into a working script?
__________________
-garrett
garrett63@msn.com
Forum Sponsor
  #2  
Old 12-10-2003
oombera's Avatar
Registered User
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Give this a try:

diff file1 file2 | sed -e 's/^</file1:/g' -e 's/^>/file2:/g'
  #3  
Old 12-10-2003
Registered User
 

Join Date: Sep 2003
Location: denver
Posts: 3
I am writing this to use as a shell script, that I can run on multiple files by typing just: mydiff firstfile secondfile

I have been working and have this code:

diff $1 $2 | sed -e 's/^<*/file1:/g' -e 's/^>*/file2:/g'


I type: mydiff firstfile secondfile
It is running the diff but output comes out like this:

file2:file1:>
file2:file1:>
file2:file1:>
file2:file1:>

Thanks for the reply
__________________
-garrett
garrett63@msn.com
  #4  
Old 12-10-2003
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
oombera's reply works all you have to do is replace diff file1 file2 w/ diff $1 $2 and it works from a shell script.
  #5  
Old 12-10-2003
Registered User
 

Join Date: Sep 2003
Location: denver
Posts: 3
Thanks for the replies I had it working in my second post, I was just confused by the output. It is working smoothly now. Thanks eveyone
__________________
-garrett
garrett63@msn.com
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0