Results 1 to 1 of 1
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-09-2010 #1
- Join Date
- Sep 2010
Access script output as file without disk space burden?
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).
$ mkfifo 4thLine $ sed '1,3 d' fileWithManyLines.txt | sed '2,99999 d' > 4thLine & # extract 4th line from fileWithManyLines.txt $ cat 4thLine
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
$ make 4thLine $ cat 4thLine $ rm 4thLine
- 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?