0% found this document useful (0 votes)
41 views1 page

Mylink C

The document describes how a C program uses the link function to create a hard link between two files, so that both file names can be used to access the same file contents and modifying one file also modifies the other.

Uploaded by

Komal nadakuditi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views1 page

Mylink C

The document describes how a C program uses the link function to create a hard link between two files, so that both file names can be used to access the same file contents and modifying one file also modifies the other.

Uploaded by

Komal nadakuditi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

$ cat mylink.c ...list the program.

main ()
{
link ("original.txt", "another.txt");
}
$ cat original.txt ...list original file.
this is a file.
$ ls -lG original.txt another.txt ...examine files before.
another.txt not found
-rw-r--r-- 1 glass 16 May 25 12:18 original.txt
$ ./mylink ...run the program.
$ ls -lG original.txt another.txt ...examine files after.
-rw-r--r-- 2 glass 16 May 25 12:18 another.txt
-rw-r--r-- 2 glass 16 May 25 12:18 original.txt
$ cat >> another.txt ...alter "another.txt".
hi
^D
$ ls -lG original.txt another.txt ...both labels reflect change.
-rw-r--r-- 2 glass 20 May 25 12:19 another.txt
-rw-r--r-- 2 glass 20 May 25 12:19 original.txt
$ rm original.txt ...remove original label.
$ ls -lG original.txt another.txt ...examine labels.
original.txt not found
-rw-r--r-- 1 glass 20 May 25 12:19 another.txt
$ cat another.txt ...list contents via other label.
this is a file.
hi
$ _

You might also like