 |
 |
Help removing "numbers" when using diff?
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Feb 2003
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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...
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Feb 2003
Status:
Offline
|
|
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
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |