pid name tid mod state data
--------------------------------------------------------------------------------
39523 srv0051_0001_0 39642 20-10:59:28 Working 820000:500196:500077
43137 srv0051_0005_0 43156 20-10:59:28 Working 820000:4250501:840057
43895 srv0051_0006_0 43903 20-10:59:28 Working 820000:4250501:840057
47523 srv0051_0009_0 47547 20-10:59:28 Working 600005:4250501:4250846
48841 srv0051_0010_0 48851 20-10:59:28 Working 600005:4290000:4290000
58182 srv0051_0020_0 58188 20-10:59:28 Working 820000:4250501:840057
8297 srv0079_0008_0 8316 20-10:59:27 Working 600005:3070001:3050012
pid,name,tid,mod,state,appnbr,request,tasknbr,appctx,username
39523,srv0051_0001_0,39642,20-10:59:28,Working,820000,500196,500077
43137,srv0051_0005_0,43156,20-10:59:28,Working,820000,4250501,840057
43895,srv0051_0006_0,43903,20-10:59:28,Working,820000,4250501,840057
47523,srv0051_0009_0,47547,20-10:59:28,Working,600005,4250501,4250846
48841,srv0051_0010_0,48851,20-10:59:28,Working,600005,4290000,4290000
58182,srv0051_0020_0,58188,20-10:59:28,Working,820000,4250501,840057
8297,srv0079_0008_0,8316,20-10:59:27,Working,600005,3070001,3050012
ベストアンサー1
sed '
# delete the 2nd line
2d
# remove any leading whitespace
s/^[[:blank:]]\+//
# on line 1, replace "data" with other words
1s/data/appnbr request tasknbr appctx username/
# replace any sequences of whitespace with comma
s/[[:blank:]]\+/,/g
# replace the 3rd and subsequent colons
s/:/,/3g
' file
s///3g
これにはGNU sedが必要です。