我将按以下格式从特定应用程序获取输出:
47114 test RUN test_medium_ciara fea-admin ciara08:ciara08:ciara08:ciara08:ciara08:ciara08:ciara08:ciara08:ciara02:ciara02:ciara02:ciara02:ciara02:ciara02:ciara02:ciara02 rw 01/10-11:12:23 default 000:30:54.00 11162 0 24133,24134,24136,24177,24248,248
我想计算第6个字段中的唯一值:
ciara08:ciara08:...
示例输出
47114 test RUN test_medium_ciara fea-admin 2 rw 01/10-11:12:23 default 000:30:54.00 11162 0 24133,24134,24136,24177,24248,248
编辑:
47117 test RUN abaqus_medium fea-admin r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09 mox 01/10-11:37:10 default 008:17:45.00 18025 21239 78836,78840,78842,78852,78880,78935,78938,78951,78939,78940,78941,78942
47123 test RUN abaqus_medium fea-admin r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n10:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n06:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07:r50n07 td42 01/10-12:09:47 default 000:00:01.00 61 607 181931,181935,181937,181945,181975,181982 01/10-12:09:49 -
47117 test RUN abaqus_medium fea-admin r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n12:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n01:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n08:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09:r50n09 mox 01/10-11:37:10 default 008:17:45.00 18025 21239 78836,78840,78842,78852,78880,78935,78938,78951,78939,78940,78941,78942
使用@ RavinderSingh13脚本输出:
$ awk '{num=split($6, A,":");for(i=1;i<=num;i++){B[A[i]]};$6=length(B);print}' test.txt
47117 test RUN abaqus_medium fea-admin 4 mox 01/10-11:37:10 default 008:17:45.00 18025 21239 78836,78840,78842,78852,78880,78935,78938,78951,78939,78940,78941,78942
47123 test RUN abaqus_medium fea-admin 7 td42 01/10-12:09:47 default 000:00:01.00 61 607 181931,181935,181937,181945,181975,181982 01/10-12:09:49 -
47117 test RUN abaqus_medium fea-admin 7 mox 01/10-11:37:10 default 008:17:45.00 18025 21239 78836,78840,78842,78852,78880,78935,78938,78951,78939,78940,78941,78942
我打赌sed或awk,但我有点困惑
答案 0 :(得分:0)
你可以说:
awk '{num=split($6, A,":");for(i=1;i<=num;i++){B[A[i]]};$6=length(B);delete(B);print}' Input_file
以下内容不会继续添加数组B的长度(感谢OP提及它)。
SimpleAsyntaskExecutor