4

Let's say that I have files f1, ..., f9. I want to create a single view -- or a soft link -- say f, that displays a concatenated view over the 9 files.

For example, if I execute wc -l f the answer should be the sum of all individual wc -l fi for i in 1 to 9. If I edit any single file fi then the view f should automatically update, such as its modification time. So basically f is a soft link that tracks a sequence of files.

Is there any filesystem that supports something like this?

  • Would shell globbing work? wc -l f* – jesse_b Jan 31 '19 at 16:55
  • 1
    For which commands do you want this 'soft link concatenation'? – sudodus Jan 31 '19 at 17:03
  • 1
    Standard Unix doesn't have this but GNU/Hurd or Plan9 might, using some sort of special file that concatenates the set of files when read. But I don't know enough about those systems to say something constructive. – Kusalananda Jan 31 '19 at 17:07
  • @Kusalananda Linux can do that too with FUSE; but I'm not aware of any ready-made thing doing exactly that kind of thing (That kind of concatenation usually done at volume/device rather than file/inode level). Anyways, this has nothing to do with symlinks. –  Jan 31 '19 at 17:40
  • 1
    Real duplicate: https://unix.stackexchange.com/q/94041/237982 – jesse_b Feb 02 '19 at 19:37

1 Answers1

3

Depending on what you are planning to do a function might meet your requirements:

cf () { cat /path/to/f1 /path/to/f2 /path/to/f3; }

It wouldn't act as a file per say but you could use process substitution to fake it:

wc -l < <(cf)

Or in the example of wc -l it may be easier to just:

cf | wc -l
jesse_b
  • 37,005