[Help-bash] How to make sure >() is finished when a command line is fini
From:
Peng Yu
Subject:
[Help-bash] How to make sure >() is finished when a command line is finished?
Date:
Sat, 21 Apr 2018 21:59:58 -0500
In the following example, 'o: stdout' is printed after the second
command line is called. Is there a way to make sure it is finished
when the first command line is finished? Thanks.
$ ./main.sh
./script.sh > >(awk -v oprefix='o: ' '{print oprefix $0; fflush(); }')
awk -v oprefix='o: ' '{print oprefix $0; fflush(); }'
stderr
./script.sh 2> >(awk -v eprefix='e: ' '{print eprefix $0 >>
"/dev/stderr"; fflush(); }')
awk -v eprefix='e: ' '{print eprefix $0 >> "/dev/stderr"; fflush(); }'
o: stdout
stdout
e: stderr
$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
set -v
./script.sh > >(awk -v oprefix='o: ' '{print oprefix $0; fflush(); }')
./script.sh 2> >(awk -v eprefix='e: ' '{print eprefix $0 >>
"/dev/stderr"; fflush(); }')
--
Regards,
Peng