paste -d":" 'file1' 'file2' | special_save "file1" # so that file1 would be treated in a way that would prevent problems with race condition
I know it normally doesn't work but is there any intelligent way how to avoid using temporary file? I know methods like heredoc, redirections,... but still it's not too comfortable..
Franklin52: well, I use this solution often but it seems to me a little weird to create a temporary file and rename it right away. I would expect this line:
2era:
> One clever workaround I stumbled on in these forums a few weeks ago used backticks to get the data out of the destination file before overwriting it.
Thank you! I like the solution but it would not work properly with escape sequences, would it? Chars like "\n" are not treated as escape sequence unless switch -e is enabled - and this switch is not in single unix specification.
You are right that echo is not portably safe, but then printf might not be available on legacy platforms either. If it's available, it's a good solution.
I have a var="`dd if=/dev/zero`" running in another window. So far, it's looking like it's only constrained by available memory. Actually I think I'll kill it now ... 11GB so far, with no particular indication that we would hit the limit any time soon. But this is probably highly platform-dependent.