请教关于shell脚本含空格字符串提取的问题
现在我的目的是这样,比如我有一个diskutilinfo/dev/disk0它执行以后返回的是硬盘的信息,如下DeviceIdentifier:disk0DeviceNo...
现在我的目的是这样,比如我有一个diskutil info /dev/disk0它执行以后返回的是硬盘的信息,如下
Device Identifier: disk0
Device Node: /dev/disk0
Whole: Yes
Part of Whole: disk0
Device / Media Name: INTEL SSDPEKKW512G7
Volume Name: Not applicable (no file system)
Mounted: Not applicable (no file system)
File System: None
Content (IOContent): GUID_partition_scheme
OS Can Be Installed: No
Media Type: Generic
Protocol: PCI-Express
SMART Status: Not Supported
Disk Size: 512.1 GB (512110190592 Bytes) (exactly 1000215216 512-Byte-Units)
Device Block Size: 512 Bytes
Read-Only Media: No
Read-Only Volume: Not applicable (no file system)
Device Location: Internal
Removable Media: Fixed
Solid State: Yes
OS 9 Drivers: No
Low Level Format: Not supported
现在我想取出来中间这部分Device / Media Name:后面的硬盘名称(硬盘名称内部可能含有一个活多个空格,但是取出来的空格不能被剔除),要用怎样的命令呢?麻烦大神解答下 展开
Device Identifier: disk0
Device Node: /dev/disk0
Whole: Yes
Part of Whole: disk0
Device / Media Name: INTEL SSDPEKKW512G7
Volume Name: Not applicable (no file system)
Mounted: Not applicable (no file system)
File System: None
Content (IOContent): GUID_partition_scheme
OS Can Be Installed: No
Media Type: Generic
Protocol: PCI-Express
SMART Status: Not Supported
Disk Size: 512.1 GB (512110190592 Bytes) (exactly 1000215216 512-Byte-Units)
Device Block Size: 512 Bytes
Read-Only Media: No
Read-Only Volume: Not applicable (no file system)
Device Location: Internal
Removable Media: Fixed
Solid State: Yes
OS 9 Drivers: No
Low Level Format: Not supported
现在我想取出来中间这部分Device / Media Name:后面的硬盘名称(硬盘名称内部可能含有一个活多个空格,但是取出来的空格不能被剔除),要用怎样的命令呢?麻烦大神解答下 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询