- 論壇徽章:
- 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
復(fù)制代碼- 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.
復(fù)制代碼- man sed
- -u, --unbuffered
- load minimal amounts of data from the input files and flush the output buffers more
- often
復(fù)制代碼 我的理解,awk和sed串在管道里時(shí),不是行緩沖方式,不會(huì)按行沖洗緩存,導(dǎo)致數(shù)據(jù)再awk積累。最后一個(gè)sed之所以不用指定緩沖方式,是因?yàn)樗切芯彌_方式,遇到換行就會(huì)輸出。 |
|