# Chapter 10. Linking, Renaming, and Copying Files

#### Contents:

What's So Complicated About Copying Files
What's Really in a Directory?
Files with Two or More Names
More About Links
Creating and Removing Links
Stale Symbolic Links
Linking Directories
Showing the Actual Filenames for Symbolic Links
Renaming, Copying, or Comparing a Set of Files
Renaming a List of Files Interactively
One More Way to Do It
Copying Directory Trees with cp -r
Copying Directory Trees with tar and Pipes

## 10.1. What's So Complicated About Copying Files

At first glance, there doesn't seem to be enough material to fill an entire chapter with information about linking, moving, and copying files. However, there are several things that make the topic more complex (and more interesting) than you might expect:

- In addition to moving and copying files, Unix systems also allow you to link them -- to have two filenames, perhaps in different directories or even on different filesystems, that point to the same file. Section 10.3 explores the reasons why you want to do that; Section 10.4 discusses the difference between "hard" and "soft" links; Section 10.5 demonstrates how to create links; and other articles discuss various issues that can come up when using links.

- It's nontrivial to rename a group of files all at once, but Unix provides many ways to circumvent the tedium of renaming files individually. In the chapter you'll see many different ways to do this, exploring the variety in the Unix toolbox along the way.

- In a hierarchical filesystem, you're sometimes faced with the problem of moving not only files but entire directory hierarchies from one place to another. Section 10.12 and Section 10.13 demonstrate two techniques you can use to perform this task.

-- TOR

Copyright © 2003 O'Reilly & Associates. All rights reserved.