Hi Forum!

I would like to
- store pictures and access rectangular parts of them in separate files without having to store the part in a separate file
- store the original emails, but have access to attachments as separate files without the additional disk space of the extracted attachment
- make the results of other complicated but quick file operations accessible as files without the hard disk storage burden of the result.

I have two solutions in my mind, but I'm not satisfied with either of them. The first solution is the named pipe approach, the second one is the makefile approach.

1. the named pipe approach

The bash snippet below takes a file with many lines. Extracts the 4th line and makes it available as a separate special file (a named pipe).
Code:
$ mkfifo 4thLine
$ sed '1,3 d' fileWithManyLines.txt | sed '2,99999 d' > 4thLine & # extract 4th line from fileWithManyLines.txt
$ cat 4thLine
Instead of the sed line one could be written that automatically restarts when the fifo was read to the end of file.

The disadvantages I see of the named pipe approach are that
- it keeps a bash instance in the system memory. Having lots of them may be infeasible.
- Only one application can read the fifo without trouble.

2. the makefile approach

I could move the sed command (and even more complicated generation algorithms) into a makefile, setting 4thLine as a make target. This way I could
Code:
$ make 4thLine
$ cat 4thLine
$ rm 4thLine
The disadvantage I see of the makefile approach are that
- I have to somehow detect that the 4thLine file will be needed and make it
- I have to somehow detect when the file is not any more needed and delete it.

Could you suggest me a fix to these or an other solution without these disadvantages?

Thanks

-- hardlink