我试图处理一个包含多个条目的文本文件,我对包含名称、Id、大小和Page83 ID的文本的数据字段感兴趣。
Command: show PhysicalDisk name='IBM (721)'
Status: Success
Time: 2017-06-30 15:50:50,051 EST
Data:
Name = IBM (721)
Id = 0004fb0000180000d27ba1c974a69157
Size (GiB) = 15.0
Shareable = No
Page83 ID = 360050768018385ace800000000000d6a
Thin Provision = Yes
VolumeGroup = Generic_SAN_Volume_Group @ Unmanaged FibreChannel Storage Array [FibreChannel Volume Group]
San Server = Unmanaged FibreChannel Storage Array [Unmanaged FibreChannel Storage Array]
Command: show PhysicalDisk name='IBM (722)'
Status: Success
Time: 2017-06-30 15:50:53,636 EST
Data:
Name = IBM (730)
Id = 0004fb0000180000627770ff185759b6
Size (GiB) = 100.0
Shareable = No
Page83 ID = 360050768018385ace800000000000d6b
Thin Provision = Yes
VolumeGroup = Generic_SAN_Volume_Group @ Unmanaged FibreChannel Storage Array [FibreChannel Volume Group]
San Server = Unmanaged FibreChannel Storage Array [Unmanaged FibreChannel Storage Array]我想要处理这个文本,并把它放在excel工作表行和列中。

这只是两个数据字段的示例输出。还想知道如何才能在数据字段的"N号“中找到这一点。
发布于 2017-06-30 07:13:50
要将一个简单的逗号分隔的csv导入到excel中,可以使用以下内容
sed -n '/Name = /!d
N;N;N;N
y/\n/,/
s/, *Shareable = [^,]*//
s/[^,=]*= //g;p' yourfile第一行删除除Name =行以外的所有行。只对这些行继续,并使用N将接下来的四行附加到缓冲区中。y命令用分隔逗号替换行之间的换行符。第一个s命令移除Shareable行,第二个命令删除部分直到=,只留下值。它适用于任意数量的行。在这种情况下,文本字段将被自动识别,没有引号。
https://unix.stackexchange.com/questions/374336
复制相似问题