Discovered an interesting thing today playing around find linux command.
The idea was to process several files in a directory using some utility that directs output to stdout. In order to keep tracking it’s useful to have a status file with a list of already processed files.
My first thought was to use something like this:
1
|
|
but the problem is that all commands pulled using exec share same output channel. It means utility output is redirected to status_file.txt as well instead of stdout that is certainly not what I wanted.
Simle command chaining using ‘;’ or ‘&&’ does not work for find exec directly so I’ve decided to wrap commands with sh/bash:
1
|
|
In this case output redirect works as expected. Probably more elegant solution exists but who cares.