Skip to content
Snippets Groups Projects
Commit 8cbb37c0 authored by nimrod's avatar nimrod
Browse files

Add dt (delayed tee), like tee but can output to the file that's being read...

Add dt (delayed tee), like tee but can output to the file that's being read from (for example sort foo.txt | dt foo.txt).
parent f45ac64f
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
set -eu
[ "$#" -gt '0' ] || { echo "Output not specified." >> /dev/stderr; return 1; }
while [ "$#" -gt '1' ]
do
args="${args:-} $1"
shift
done
tempfile="$(mktemp -p .)"
# shellcheck disable=SC2086
tee ${args:-} "$tempfile" && mv "$tempfile" "$1"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment