Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: View the new 'man' pages on upgraded systems System 10.5
In Leopard, many man pages (the documentation for Mac OS X's UNIX commands) are compressed with gzip. This is a very good idea but, if you upgraded to Leopard from Tiger, the old man pages are left in place by the installer (this is a bug).

So many man pages are there in two versions: the old uncompressed one from Tiger, and the new compressed one from Leopard. The problem is that when man searches for a given page, it finds the uncompressed one first and displays it, thus showing you outdated information. To solve the problem, the old man pages must be removed. I made a shell script that removes everything in /usr/share/man that is not installed by Leopard (I made the script by actually installing Leopard on a blank disk and comparing with my installed system). Here's the command to build the script: This command creates a shell script (in the directory from which it was run) containing rm commands for all man pages that are not in the Leopard clean install. You can then execute it by typing sudo sh rm-old-man.sh. If you want to try it, here's the script that I generated on my system [23KB download], which I think you can safely execute on any Leopard system. However, back up first -- you have been warned.

[robg adds: I haven't tested this one, nor can I confirm the issue, as my machines were all clean installs.]
    •    
  • Currently 3.60 / 5
  You rated: 3 / 5 (5 votes cast)
 
[12,394 views]  

10.5: View the new 'man' pages on upgraded systems | 27 comments | Create New Account
Click here to return to the '10.5: View the new 'man' pages on upgraded systems' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: View the new 'man' pages on upgraded systems
Authored by: JazzDude on Dec 13, '07 08:18:22AM
I can't confirm this issue for an upgrade install. Here's a screenshot of my "man1" folder (10.4.11 upgraded to 10.5.0, then 10.5.1):
http://pygmytwylyte.org/pics/man.png



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: matsw on Dec 13, '07 08:39:50AM

Looks good to me. How and from what version did you upgrade ?



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: dh on Dec 13, '07 08:31:52AM

According to the description of the problem gzipped man files are from the Leopard upgrade while the standard .1, etc. files are from Tiger. Yet, the rm-old-man.sh script that this generates seems to occasionally rm both the .1 and the .1.gz files. For example,
rm /usr/share/man/man1/appleping.1
rm /usr/share/man/man1/appleping.1.gz



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: matsw on Dec 13, '07 08:42:55AM

Did you really make a clean install of Leopard on another disk to compare with ? If not, please use the rm-old-man.sh.gz that is linked to in the hint.



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: dbs on Dec 13, '07 08:32:42AM
The script posted in the forums for X11 under: http://forums.macosxhints.com/showthread.php?t=80171&page=3 works very well. I ran it and it did what it said. I backed up my /usr/share/man directory first, though.

The problem with this issue is that everything works, you just see old information. E.g., if you do "man syslog" you will NOT see an entry for the "-C" command if you have the old man pages installed.

[ Reply to This | # ]
Prebaked script worked for me.
Authored by: SosarianBeastie on Dec 13, '07 08:44:51AM

Having not done a clean install, and noting that I indeed had the duplicate man entries, I was happy to read this tip.

Not having the patience to do a virgin Leopard install (and a separate virgin Tiger+Leopard install) in order to generate the script, I just downloaded the tip author's prebaked script and looked through it -- only one .gz file was listed in it, without a corresponding .1 file. This was presumably an actual .gz file from the Tiger install which does not exist in Leopard.

dh, perhaps you didn't set up your volumes correctly for the creation of this script?



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: wscody on Dec 13, '07 08:57:33AM

Sorry, but this didn't work for me. It wiped out ALL my man pages. I upgraded from Tiger. Use with caution!



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: yuji on Dec 13, '07 09:07:14AM
Here's my version of the perl script. Save it in a file (say remove_duplicates.pl), cd to /usr/share/man, and sudo perl remove_duplicates.pl. It just backs up the old man pages in /usr/share/man/duplicates/ , and never removes it.

use File::stat;
mkdir "duplicates" unless -e "duplicates";
for $dir (<man*>){
	unless(-e "duplicates/$dir"){
		mkdir "duplicates/$dir";
	}
	($id)=($dir=~/man(.*)/);
	for(<$dir/*.$id>){
		if(-e "$_.gz"){
			$st=lstat($_);
			$gz=lstat("$_.gz");
			if($st->mtime < $gz->mtime ){
				print "$_ older than $_.gz \n";
				rename $_, "duplicates/$_";
			}
		}
	}
}


[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: sEEKz on Dec 13, '07 09:19:08AM
There is an issue. Especially if you use a case sensitive filesystem. It seems that in Tiger several files start with an uppercase letter. Whereas in Leopard all the .gz files are lowercase. For example:

larik@hustler mann $ ls -al widget.n.gz Widget.n 
-rw-r--r--  1 root  wheel  3568 Dec 13 17:39 Widget.n
-rw-r--r--  1 root  wheel  2528 Dec 13 17:39 widget.n.gz
The following code can be used, just to remove all files which have an .gz equivalent. (You don't need the Leopard install DVD). Backup first and use at your own risk.

for f in $(find /usr/share/man -type f \! -iname '*.gz'); do
   lc=`echo $f | tr "[:upper:]" "[:lower:]"`
   ( [ -e ${f}.gz ] || [ -e ${lc}.gz ] ) && rm $f 
done


[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: matsw on Dec 13, '07 09:34:33AM

IMPORTANT INFORMATION FROM THE ORIGINAL HINT AUTHOR:

The way the hint is posted is misleanding because it makes the "for f ..." script in the box stand out. The "for f ..." script is the complicated way of doing things and REQUIRES A SEPARATE CLEAN INSTALL OF LEOPARD. If you don't have the right setup, all your man pages will be deleted.

So for most people, I recommend executing the script rm-old-man.sh.gz that is linked to in the hint as [23KB download] (you have to decompress is first).



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: ershler on Dec 13, '07 10:09:11AM

If this way of doing things is ore difficult AND requires a fresh install of 10.5, what sense does it make to do anything but a fresh install of 10.5. Doesn't a fresh install of 10.5 make this issue of left over 10.4 man pages moot?



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: bschoate on Dec 13, '07 10:02:15AM

Here's a tip -- instead of posting scripts or instructions that removes files, use 'mv ... ~/Trash/' instead, so at least there's a way to undo it if it goes wrong! I haven't tried this myself, but I could imagine that some of the man pages listed in the attached script may not have come from a Tiger install, but perhaps from other tools.

I'd ask that macosxhints.com make this a policy, frankly. No 'rm' commands in published tips!



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: bschoate on Dec 13, '07 10:03:41AM

(~/.Trash/, that is)



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: bschoate on Dec 13, '07 10:17:04AM

OK, so I tried this script and here's what happened. I modified it to mv the files instead of deleting them. It only moved 9 files in the end, and all of them were man files that were installed AFTER Leopard. I wound up moving them all back, since they were newer.

So this tip has zero value, at least for me. May be harmful for most users that have installed custom tools on top of Tiger and/or Leopard.



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: liyanage on Dec 13, '07 10:15:56AM

This command will give a list of the commands required to remove the old files:

sudo find /usr/share/man -type f -exec test -e {}.gz \; -exec echo rm {} \;

If you are happy with the results, you can remove the "echo" to delete the files. I did just that on my machine and now I'm fine.

Thanks for this hint. I was wondering why man bash and Bwana were still showing the man page for bash version 2.05 instead of 3 (Bwana also required cleaning of its cache dir ~/Library/Caches).



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: liyanage on Dec 13, '07 10:17:11AM

That's ~/Library/Caches/Bwana...



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: liyanage on Dec 13, '07 11:39:40AM

Another correction, the -type f needs to go, lots of old symbolic links are missed otherwise.

That makes it

sudo find /usr/share/man -exec test -e {}.gz \; -exec echo rm {} \;

[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: richwiss on Dec 13, '07 07:50:16PM
Before you delete all the files, you can save them all in a tar archive:

sudo find /usr/share/man -exec test -e {}.gz \; -exec tar --absolute-names -rzvf ~/man.tgz {} \;

I should note that I had no problems running this command without leading sudo, so you may wish to omit that.

There might be a smarter way to first list all the files and then form the archive, but this only took 1 minute and 41 seconds.

If you ever need to restore: tar xzf ~/man.tgz will put them all back.

[ Reply to This | # ]

10.5: View the new 'man' pages on upgraded systems
Authored by: muckilius on Dec 14, '07 10:58:52AM
summary of the privious posts:

if you have ugraded form tiger to leopard, the old man-pages are still remain on your system. Follow the the steps to remove the old man-pages.
1. Make a backup of all you man pages:

sudo find /usr/share/man -exec test -e {}.gz \; -exec tar --absolute-names -rzvf ~/man.tgz {} \;
2. preview of the delete-command (It will only echo the rm -command.)

sudo find /usr/share/man -type f -exec test -e {}.gz \; -exec echo rm {} \;
3. If you are statisfied with the result of (2.) the you can delete all old man pages:

sudo find /usr/share/man -type f -exec test -e {}.gz \; -exec rm {} \;

Later you can delete your backup ~/man.tgz or you can restore it with tar xzf ~/man.tgz

[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: wscody on Dec 17, '07 07:57:37AM

This hint appeared to work, however, when I went to delete the saved man pages (man.tgz) I could not the file anywhere.

Any ideas where man.tgz went???



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: alanb1979 on Jan 23, '08 10:23:12AM
This worked well for me except that I had to move fink's tar program out of the way while doing the update so that it used OSX's tar. Fink's tar gave the following error:
tar cannot update compressed archives

---
hiedy hoo

[ Reply to This | # ]

10.5: View the new 'man' pages on upgraded systems
Authored by: alanb1979 on Jan 23, '08 02:35:14PM

Actually I had the same problem as wscody where the man.tgz didn't show up. Turns out the z option that compresses the man pages was the problem. Maybe it is another fink conflict but I just bypassed it. The resulting man.tar file came out to about 40MB.

find /usr/share/man -exec test -e {}.gz \; -exec /usr/bin/tar -rvPf ~/man.tar {} \;

Now that the man files are all backed up, I want to verify that I indeed have both the old and new manuals. For example, the bash manual should be for bash 3, not 2.05. The following tells me there are 2 bash manuals the bash.1 modified 30-Mar-2005 while the bash.1.gz is from 23-Sep-2007.

ls -l /usr/share/man/man1/bash.*

-rw-r--r-- 1 root wheel 228193 Mar 20 2005 /usr/share/man/man1/bash.1
-rw-r--r-- 1 root wheel 70941 Sep 23 20:41 /usr/share/man/man1/bash.1.gz

Then, I did the following sequence, including the removal of the -type f as suggested by livanage.

sudo find /usr/share/man -exec test -e {}.gz \; -exec echo rm {} \;

sudo find /usr/share/man -exec test -e {}.gz \; -exec rm {} \;

Now to verify that the bash.1 file is gone.

ls -l /usr/share/man/man1/bash.*

-rw-r--r-- 1 root wheel 70941 Sep 23 20:41 /usr/share/man/man1/bash.1.gz

And man now uses the correct page.

man -w bash

/usr/share/man/man1/bash.1.gz

---
hiedy hoo

[ Reply to This | # ]

10.5: View the new 'man' pages on upgraded systems
Authored by: RobLewis on Dec 14, '07 08:32:16PM

OK, I was warned. I went ahead and did it and I think it erased ALL my man pages. Fantastic! What do I do now to get them back?

I only have the Tiger-->Leopard upgrade DVD that came with the new iMac.

Whoever posted this hint is a bad person. And I'm a dumb person.



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: rishi on Dec 16, '07 11:09:06PM

Me too. Any idea which pkg in the leopard dvd has the man pages so I can reinstall them.



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: rishi on Dec 17, '07 01:30:58PM

If you like me, erased all the man pages, you could use Pacifist with your Leopard Install disk to just reload the man pages.



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: hgk on Feb 21, '08 05:30:37AM

Thanks guys, the last summary did the trick,
but how do I now batch-unpack all those tar files (which I still find in the directories?)

Cheers



[ Reply to This | # ]
10.5: View the new 'man' pages on upgraded systems
Authored by: jabial on Mar 04, '08 07:50:36AM

The find -type f trick is good, but you also need to do another one with -type l to take into accound the symbolic links to the old man pages, which need to be removed also.

Personnally I used
<code>
sudo mkdir /usr/share/man/old
sudo find /usr/share/man -type f -exec test -e {}.gz \; -exec mv {} /usr/share/man/old \;
sudo find /usr/share/man -type l -exec test -e {}.gz \; -exec mv {} /usr/share/man/old \;
</code>

That way you can restore the files if the command fails - which I doubt if you copy it correctly. I'll delete the /usr/share/man/old directory after a month if I encounter no problems.



[ Reply to This | # ]