Difference between copy and link (was: Re: os.link makes a copy, not a link)

Ben Finney bignose+hates-spam at benfinney.id.au
Fri Jun 9 20:22:56 EDT 2006


Dan M <dan at catfolks.net> writes:

> I'm a little bit confused. According to the sources I've looked at on the
> net, 
>     os.link('file1', 'file2')
> should make a hard link from file1 to file2. But what I'm finding is that
> it's actually making a copy. Am I forgetting a step or something?

Are you sure that's what it's doing? Do you know the difference
between a copy and a hard link?

$ echo "Lorem ipsum" > foo.txt
$ ln foo.txt bar.txt
$ cp foo.txt baz.txt
$ ls -l *.txt
-rw-r--r-- 2 bignose bignose 12 2006-06-10 10:16 foo.txt
-rw-r--r-- 2 bignose bignose 12 2006-06-10 10:16 bar.txt
-rw-r--r-- 1 bignose bignose 12 2006-06-10 10:17 baz.txt
$ cat foo.txt
Lorem ipsum
$ cat bar.txt
Lorem ipsum
$ cat baz.txt
Lorem ipsum

-- 
 \        "Good judgement comes from experience. Experience comes from |
  `\                           bad judgement."  -- Frederick P. Brooks |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list