- 论坛徽章:
- 1
|
- #!/bin/sh
- (
- echo 1111111111111111111
- echo 2222222222222222222
- echo 3333333333333333333
- echo 4444444444444444444
- echo 5555555555555555555
- echo 6666666666666666666
- sleep 9
- echo DONE
- ) \
- | awk '(!($0 ~ " ABCD ") || $0 ~ "WWWWWWWWWWWW from XXXXXX" || $0 ~ " REM "){print;fflush()}' \
- | sed -u "s/\(^..:..:.. SQL> \).*REM \(.*\)/\1REM \2/" \
- | sed "s/\(^..:..:.. SQL> \).*REM \(.*\)/\1REM \2/"
- exit 0
复制代码- man awk
- fflush([file]) Flush any buffers associated with the open output file or pipe file. If
- file is missing, then standard output is flushed. If file is the null
- string, then all open output files and pipes have their buffers flushed.
复制代码- man sed
- -u, --unbuffered
- load minimal amounts of data from the input files and flush the output buffers more
- often
复制代码 我的理解,awk和sed串在管道里时,不是行缓冲方式,不会按行冲洗缓存,导致数据再awk积累。最后一个sed之所以不用指定缓冲方式,是因为他是行缓冲方式,遇到换行就会输出。 |
|