#!/bin/bash
current_host=""
while IFS= read -r line; do
# 检测是否是主机名行
if [[ $line =~ ^kj[a-zA-Z0-9]* ]]; then
# 如果是新的主机名,则记录它
current_host="$line"
#if [[ -n $current_host ]]; then
echo "--------------------"
#fi
else
# 检查设备信息行是否包含 "T"(类型是 disk)
if [[ $line == *"T"* ]]; then
device_type=$(echo "$line" | awk '{print $6}')
#echo "$device_type"
device=$(echo "$line" | awk '{print $1}')
#echo "$device"
mountpoint=$(echo "$line" | awk '{print $NF}')
# 检查设备类型是否为 "disk" 或 "part"
if [[ "$device_type" == "disk" || "$device_type" == "part" ]]; then
if [[ "$device" == *sd* ]]; then
# 检查是否没有挂载点
if [ -z "$mountpoint" ] || [[ "$mountpoint" != /* ]]; then
echo "$current_host | $line"
fi
fi
fi
fi
fi
done < data.txt
(#输出结果需输出到data.txt)