Ako zistit ci dany subor je link?

Jozef Drahovsky freebsdcz2 at jozef.drahovsky.sk
Sun Apr 10 01:54:57 CEST 2016


Ako zistit ci dany subor je link?
pokus na R10.3/64

# mkdir /a
# mkdir /b

# echo "prvy" > /a/subor1.txt
# echo "prvy" > /a/subor2.txt
# echo "prvy" > /a/subor3.txt
# ln -s /a/subor1.txt /b/subor1.txt
# ln /a/subor2.txt /b/subor2.txt
# cp /a/subor3.txt /b/subor3.txt

# ls -l /b
lrwxr-xr-x  1 root  wheel  13 Apr 10 01:30 subor1.txt -> /a/subor1.txt
-rw-r--r--  2 root  wheel   5 Apr 10 01:30 subor2.txt
-rw-r--r--  1 root  wheel   5 Apr 10 01:30 subor3.txt

# echo "druhy" >> /a/subor1.txt
# echo "druhy" >> /a/subor2.txt
# echo "druhy" >> /a/subor3.txt


# ls -l /b
lrwxr-xr-x  1 root  wheel  13 Apr 10 01:30 subor1.txt -> /a/subor1.txt
-rw-r--r--  2 root  wheel  11 Apr 10 01:31 subor2.txt
-rw-r--r--  1 root  wheel   5 Apr 10 01:30 subor3.txt

podla coho rozoznam, ktory subor je a nie je link a kam (teda okrem 
symbolickeho)?


# rm /a/*
ls -l /b
lrwxr-xr-x   1 root  wheel    13 Apr 10 01:30 subor1.txt -> /a/subor1.txt
-rw-r--r--   1 root  wheel    11 Apr 10 01:31 subor2.txt
-rw-r--r--   1 root  wheel     5 Apr 10 01:30 subor3.txt

# cat /b/subor1.txt
cat: /b/subor1.txt: No such file or directory
# cat /b/subor2.txt
prvy
druhy
# cat /b/subor3.txt
prvy
#

To ze subor1.txt neexistuje, ale link zostal je ok, to ze subor3.txt ma 
len prvy je tiez ok lebo to bola kopia a nie link
ale odklial sa zobralo telo subor2.txt ? Cize pokial je subor niekde 
systemovo zalinkovany tak sa fyzicky nevymaze.



# echo "treti" >> /a/subor1.txt
# echo "treti" >> /a/subor2.txt
# echo "treti" >> /a/subor3.txt

# ls -l /a
-rw-r--r--  1 root  wheel  6 Apr 10 01:36 subor1.txt
-rw-r--r--  1 root  wheel  6 Apr 10 01:36 subor2.txt
-rw-r--r--  1 root  wheel  6 Apr 10 01:36 subor3.txt
# ls -l /b
lrwxr-xr-x  1 root  wheel  13 Apr 10 01:30 subor1.txt -> /a/subor1.txt
-rw-r--r--  1 root  wheel  11 Apr 10 01:31 subor2.txt
-rw-r--r--  1 root  wheel   5 Apr 10 01:30 subor3.txt


Otazka co najdem v telach suborov?
# cat /b/subor1.txt
treti
# cat /b/subor2.txt
prvy
druhy
# cat /b/subor3.txt
prvy
#

Zaverecna a hlavna otazka ako rozoznat kedy subory /a/subor2.txt 
/b/subor2.txt su ten isty a kedy ine?


Jozef


More information about the Users-l mailing list