Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there possible to create file that is just a sub-sequence of bytes from another file, like a symlink, but referencing only part of the file?

share|improve this question
Perhaps if you explain the purpose of what you are trying to do, we could suggest a solution. – JRT Oct 20 '11 at 8:22

No. You must either reference the whole file, or you must copy the part of the file you're interested in.

share|improve this answer

Yes, it is (somewhat) possible at least on Linux with some limitations.

The method is to create a read-write loop device that maps to a subset of the file.


for ((i=0;i<10000;i++)); do
    printf "%7d\n" $i
done >/var/tmp/file
losetup -v -f -o 512 --sizelimit 512 /var/tmp/file
losetup -a
head -2 /var/tmp/file
echo ...
tail -2 /var/tmp/file
echo ===
head -2 /dev/loop0
echo ...
tail -2 /dev/loop0 
printf "I was here" > /dev/loop0
grep here /var/tmp/file
losetup -d /dev/loop0


loop device: /dev/loop0
/dev/loop0: [0808]:136392 (/var/tmp/file), offset 512, size 512
I was here   65

I believe both the offset and the size must be multiple of a block size (512 bytes).

You probably need to be root to create and access the loop device.

If you need a symlink, you can create one that points to the loop device.

share|improve this answer

It could be possible (to create a normal symlink pointing to a part of a file) on a filesystem which implements the "file as directory" idea, which appeared--besides other authors--in the plans for reiserfs, but the reiserfs's implementation wasn't liked for the problems the implementation caused.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.