csh script to find outdated symbolic links

Michael Schwartz schwartz at uw-beaver
Fri Nov 22 12:55:58 AEST 1985


Here is a csh script to find outdated symbolic links.  To my knowledge,
symbolic links are only available on 4.2BSD and 4.3BSD, so this script
is useless to people on other systems.

It is useful to run this script after moving files or directories around,
because you may have symbolic links to these files/directories that become
outdated after the move.

Usage: oldlinks <directory> [<directory>, ...]
Output: names of symbolic links (stored in the specified directory 
	hierarchies) which are outdated, if any.

 - Mike Schwartz
   University of Washington Computer Science Department
   ihnp4!uw-beaver!schwartz  (USENET)
   schwartz at wally.arpa  (ARPANET)
   schwartz%wally.arpa at csnet-relay.arpa  (CSNET)

#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#-----cut here-----cut here-----cut here-----cut here-----
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	oldlinks
# This archive created: Thu Nov 21 18:43:14 1985
echo shar: extracting oldlinks '(595 characters)'
sed 's/^XX//' << \SHAR_EOF > oldlinks
XX#!/bin/csh -f
XX# csh script to find and print outdated symbolic links, searching 
XX# (recursively) downwards into the specified directories.
XX# 	By Mike Schwartz, 11-20-85.
XX# 	University of Washington Computer Science Department
XX# 	ihnp4!uw-beaver!schwartz  (USENET)
XX# 	schwartz at wally.arpa  (ARPANET)
XX# 	schwartz%wally.arpa at csnet-relay.arpa  (CSNET)
XX
XXif $#argv == 0 then
XX	echo Usage: oldlinks \<directory\> \[\<directory\>, ...\]
XX	exit 1
XXendif
XXforeach i($*)
XX	find $i -type l -print | sed 's/\(.*\)/if !(-e \1) echo \1/' > /tmp/tstlinks.$USER
XX	source /tmp/tstlinks.$USER
XXend
XX
XXrm /tmp/tstlinks.$USER
SHAR_EOF
if test 595 -ne "`wc -c oldlinks`"
then
echo shar: error transmitting oldlinks '(should have been 595 characters)'
fi
chmod +x oldlinks
#	End of shell archive
exit 0



More information about the Comp.sources.unix mailing list