Полезная информация

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 18.13 One More Way to Do It Chapter 18
Linking, Renaming, and Copying Files
Next: 18.15 Copying Directory Trees with cp -r

18.14 Relinking Multiple Symbolic Links

Like the rename program in article 18.10, the relink program (a Perl script) relinks the symbolic links given according to the rule specified as the first argument. The argument is a Perl expression that is expected to modify the $_ string in Perl for at least some of the names specified. For each symbolic link named on the command line, the Perl expression will be executed on the contents of the symbolic link with that name. If a given symbolic link's contents is not modified by the expression, it will not be changed. If a name given on the command line is not a symbolic link, it will be ignored. If no names are given on the command line, names will be read via standard input.

For example, to relink all symbolic links in the current directory pointing to somewhere in X11R3 so that they point to X11R4, you might say:

$ relink 's/X11R3/X11R4/' *

To change all occurrences of links in the system from /usr/spool to /var/spool, you'd say:

-type l 
$ find / -type l -print | relink 's#^/usr/spool#/var/spool#'

- LW

Previous: 18.13 One More Way to Do It UNIX Power ToolsNext: 18.15 Copying Directory Trees with cp -r
18.13 One More Way to Do It Book Index18.15 Copying Directory Trees with cp -r

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System