- 论坛徽章:
- 2
|
本帖最后由 weichanghe2000 于 2018-09-03 13:56 编辑
Hi all。请教大家一个问题,
对于下面示例给出的几行,用 bash 如何提出每一行 PGID后面的数字,到数组或变量中?
即第1行输出 11710 11712
即第2行输出 6395
即第3行输出 5027 5021 5015
用perl:
...
...
- my @pgids;
- my $a;
- while ( $a =~ /PGID: (\d+);/g) {
- print "1: $1\n";
- push @pgids, $1;
- }
- ...
- ....
复制代码
bash不知道实现??
- Thu Jun 9 00:29:01: Resource usage collected. MEM: 3 Mbytes; SWAP: 137 Mbytes; NTHREAD: 4 PGID: 11710; PIDs: 11710 11711 11713; PGID: 11712; PIDs: 11712 11718 11719;
- Mon Nov 29 14:08:46: Resource usage collected. MEM: 2 Mbytes; SWAP: 32 Mbytes; NTHREAD: 1 PGID: 6395; PIDs: 6395;
- Wed Aug 13 14:23:43 2009: Started on <hostB>, Execution Home </home/user1>, Execution CWD </home/user1>; Resource usage collected. IDLE_FACTOR(cputime/runtime): 0.00 MEM: 3 Mbytes; SWAP: 4 Mbytes; NTHREAD: 3 PGID: 5027; PIDs: 5027 5028 5029; PGID: 5021; PIDs: 5021 5022 5023; PGID: 5015; PIDs: 5015 5016 5019;
- ....
- ....
- ....
复制代码
|
|