Tomáš Mudruňka wrote: > i was wroting small bash script which needs special behaviour of tee > and i needed to reimplement it.
It reads like you actually need something slightly different. You want the new file to be either the old contents or the new contents but nothing in between. Which means that you would need to write to a temporary file first and then rename it into the final location after it has been fully written. > The important lines looks like that: > > while true; do > cat "$2" | ccrypt -e -K "$3" | tee-lazy "$1"; > done & Perhaps something like this, it would need some more work: dir=$(dirname "$1") trap 'rm -f "$dir//$TMPFILE"' EXIT while true; do TMPFILE=$(mktemp "$dir//mytmpfile.XXXXXXXX") || exit 1 ccrypt -e -K "$3" < "$2" | tee "$TMPFILE" mv -f "$TMPFILE" "$1" done And much of the current topical discussion of ext4 buffer flush ordering says that the above isn't safe in the presense of system crashes. File data into $TMPFILE needs to be flushed to disk first. Bob _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
