- 论坛徽章:
- 145
|
本帖最后由 jason680 于 2014-02-07 15:42 编辑
回复 1# Pugna_zfr
which one do you like
# output file: file1, file2, ..., fileN
$ awk -vf="file" '/^Service /{++n}{print $0 > f""n}' FILE
$ grep . file?
file1:Service "syncdb" has 1 instance(s).
file1: Instance "syncdb", status READY, has 1 handler(s) for this service...
file2:Service "syncdbXDB" has 2 instance(s).
file2: Instance "syncdb1", status READY, has 1 handler(s) for this service...
file2: Instance "syncdb2", status READY, has 1 handler(s) for this service...
file3:Service "syncdb_XPT" has 1 instance(s).
file3: Instance "syncdb", status READY, has 1 handler(s) for this service...
#output file: by service name
$ awk -F'"' '/^Service /{f=$2}{print $0 > f}' FILE
$ grep . syncdb*
syncdb:Service "syncdb" has 1 instance(s).
syncdb: Instance "syncdb", status READY, has 1 handler(s) for this service...
syncdbXDB:Service "syncdbXDB" has 2 instance(s).
syncdbXDB: Instance "syncdb1", status READY, has 1 handler(s) for this service...
syncdbXDB: Instance "syncdb2", status READY, has 1 handler(s) for this service...
syncdb_XPT:Service "syncdb_XPT" has 1 instance(s).
syncdb_XPT: Instance "syncdb", status READY, has 1 handler(s) for this service...
|
|