Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16527
| From | bug-bash@trodman.com |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | bash 1-liner or function to tee to STDERR in middle of pipe? |
| Date | 2020-07-03 09:32 -0500 |
| Message-ID | <mailman.878.1593786753.2574.bug-bash@gnu.org> (permalink) |
| References | <202007031432.063EWIhD3254754@epjdn.zq3q.org> |
This does what I want:
--8<---------------cut here---------------start------------->8---
_tee_stderr ()
{
<<'____eohd'
SYNOPSIS
ourname
DESCRIPTION
Use in a pipe. Leaks STDIN to STDERR. Passes STDIN to STDOUT unchanged.
EXAMPLE
$ seq 5 |_tee_stderr |tail -2 > /tmp/bar ; echo;cat /tmp/bar
1
2
3
4
5
4
5
____eohd
( tmpf=$( mktemp ~/tmp/$FUNCNAME.XXX );
cat > $tmpf;
cat $tmpf 1>&2;
cat $tmpf;
rm -f $tmpf );
return;
}
--8<---------------cut here---------------end--------------->8---
What is better/cleaner?
--
thanks!
Back to gnu.bash.bug | Previous | Next | Find similar
bash 1-liner or function to tee to STDERR in middle of pipe? bug-bash@trodman.com - 2020-07-03 09:32 -0500
csiph-web