Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Help removing "numbers" when using diff?

Help removing "numbers" when using diff?
Thread Tools
Dedicated MacNNer
Join Date: Feb 2003
Status: Offline
Reply With Quote
Jul 11, 2003, 04:35 AM
 
Hi. A basic install script I have does an ls of adir which it shoots to a file. I then do another after an install and run diff on the two. I get the differences, but each entry is preceeded by a number. I looked at the options, how can I have the diff without numbers? These numbers are not in the original files but produced by diff.
Thanks.

ie:
0a1
> iTunes.app
28a30
> iPhoto.app
88a91
     
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
Jul 11, 2003, 08:33 AM
 
Originally posted by jgift:
Hi. A basic install script I have does an ls of adir which it shoots to a file. I then do another after an install and run diff on the two. I get the differences, but each entry is preceeded by a number. I looked at the options, how can I have the diff without numbers? These numbers are not in the original files but produced by diff.
Thanks.

ie:
0a1
> iTunes.app
28a30
> iPhoto.app
88a91
Simple... use the feature of stringing commands together like this:

diff oldlist newlist | grep \>

This will give you a list of what is in newlist but NOT in oldlist. For the other way do:

diff oldlist newlist | grep \<

Note: the \ before the > or < is neccessary otherwise the shell thinks it is a redirect of the output instead of the thing to grep for. There may be an option in diff for eliminating the line references (numbers) but I couldn't spot it in the manpage.

For real fun try diff3... does differences between three files :-)
(Last edited by utidjian; Jul 11, 2003 at 08:39 AM. )
-DU-...etc...
     
Mac Enthusiast
Join Date: Jul 2002
Location: Leiden, Netherlands
Status: Offline
Reply With Quote
Jul 11, 2003, 08:34 AM
 
Originally posted by jgift:
Hi. A basic install script I have does an ls of adir which it shoots to a file. I then do another after an install and run diff on the two. I get the differences, but each entry is preceeded by a number. I looked at the options, how can I have the diff without numbers? These numbers are not in the original files but produced by diff.
Thanks.

ie:
0a1
> iTunes.app
28a30
> iPhoto.app
88a91
I think it's "-u"
     
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
Jul 11, 2003, 08:42 AM
 
Originally posted by Ludovic Hirlimann:
I think it's "-u"
Yeah I tried that but I still get some numerical artifacts in the resulting list.
-DU-...etc...
     
jgift  (op)
Dedicated MacNNer
Join Date: Feb 2003
Status: Offline
Reply With Quote
Jul 11, 2003, 09:28 AM
 
That works. Thanks. The only problem is I was getting such a jumble of files originally that I added a heading between each ls in the second diff file. The heading is now lost and I would like to keep them...
ie:

File 1.
ls /Applications >> ~/Work/Foo.txt

File 2.
echo "# Applications #" > ~/Work/Foo-New.txt
ls /Applications >> ~/Work/Snapshot-New.txt
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:04 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2