help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function to find symlink target


From: Eli Zaretskii
Subject: Re: Function to find symlink target
Date: Sat, 28 May 2022 19:08:57 +0300

> From: Emanuel Berg <incal@dataswamp.org>
> Date: Sat, 28 May 2022 17:43:00 +0200
> 
> > How big is a symlink?
> >
> > $ touch a.txt
> > $ ln -s a.txt a-sy.txt
> > $ du -b a-sl.txt
> > 5
> >
> > 5 bytes. The path to a.txt
>               ^ relative
> 
> Yes, if one places the symlink in some another dir than the
> target then the size increases.
> 
> Observe
> 
> $ cd
> $ mkdir -p test/sl
> $ cd !:2
> $ touch a
> $ ln -s a b
> $ cd
> $ ln -s test/sl/a l
> 
> then compare
> 
> $ du -b test/sl/b
> 1     test/slb/
> 
> $ du -b l
> 9     l
> 
> Lesson: There is a lot of space to save by placing symlinks correctly!

Actually, for short enough symlinks (like shorter than 60 bytes),
there are no disk space savings at all, regardless of the actual
length of the reference target.

You evidently assume that a symlink is stored in some particular way
on disk, but the reality is different from your assumption.  What 'ls'
and 'du' show you is largely an illusion.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]