Hardlink/softlink multiple file to one file

cathard linksymlink

I have many files in a folder. I want to concatenate all these files to a single file. For example cat * > final_file; But this will increase disk space and also will consume time. Is there is a way where I can hardlink/softlink all the files to final_file? For example ln * final_file.

Best Answer

With links, I'm afraid, this will not be possible. However, you could use a named pipe. Example:

# create some dummy files
echo alpha >a
echo beta  >b
echo gamma >c

# create named pipe
mkfifo allfiles

# concatenate files into pipe
cat a b c >allfiles

The last call will block until some process reads from the pipe and then exit. For a continuous operation one can use a loop, which waits for a process to read and starts over again.

while true; do
  cat a b c >allfiles
done