From 4175efa653a5ac27cd9def690e645ba6de088249 Mon Sep 17 00:00:00 2001 From: BrainwreckedTech <3752022+BrainwreckedTech@users.noreply.github.com> Date: Tue, 11 Jan 2022 05:01:11 -0500 Subject: [PATCH] Re-arrange columns, add headers --- bdmap | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bdmap b/bdmap index 7221f2e..d448604 100755 --- a/bdmap +++ b/bdmap @@ -12,9 +12,6 @@ BLK_INFO="$(echo "${BLK_INFO}" | sed 's|\(usb[0-9]\+\)/.*/host|\1/host|g')" # STRIP OFF THE SUPERFLUOUS HOST AND TARGET INFORMATION BLK_INFO="$(echo "${BLK_INFO}" | sed 's|/host[0-9]\+/target\([0-9]\+\):\([0-9]\+\):\([0-9]\+\)/|/|g')" -# EXPAND THE SCSI INFORMATION -# BLK_INFO="$(echo "${BLK_INFO}" | sed 's|\([0-9]\+\):\([0-9]\+\):\([0-9]\+\):\([0-9]\+\)|ch\2/id\3/lun\4|g')" - # NORMALIZE NVME INFO BLK_INFO="$(echo "${BLK_INFO}" | sed 's|nvme/nvme\([0-9]\+\)/nvme\([0-9]\+\)n\([0-9]\+\)|nvme/N:\2:\3:1|g')" @@ -24,12 +21,15 @@ BLK_INFO="$(echo "${BLK_INFO}" | sed 's|/block/.*||g')" # CONVERT -> TO A SPACE BLK_INFO="$(echo "${BLK_INFO}" | sed 's/ -> / /g')" +# CONVERT / TO A SPACE +BLK_INFO="$(echo "${BLK_INFO}" | sed 's|/| |g')" + # SWAP COLUMNS -BLK_INFO="$(echo "${BLK_INFO}" | awk '{t=$1; $1=$2; $2=t; print;}')" +# BLK_INFO="$(echo "${BLK_INFO}" | awk '{t=$1; $1=$2; $2=t; print;}')" # NOW GET DEVICE IDs and SIZES -echo "${BLK_INFO}" | while read -r LOCATION BLOCKDEV; do +echo "${BLK_INFO}" | while read -r BLOCKDEV DEV_PORT DEV_HCIL; do DEVICE_ID="$(ls -l --color=never /dev/disk/by-id | sed 's/ \+/ /g' | grep -v 'nvme-eui\|wwn-' | grep "${BLOCKDEV}$" | cut -d\ -f9)" DEV_BYTES="$(lsblk -bnPo NAME,SIZE | grep "\"${BLOCKDEV}\"" | cut -d\" -f 4)" if [ "${DEV_BYTES}" -ge $((1000**5)) ]; then @@ -45,8 +45,8 @@ echo "${BLK_INFO}" | while read -r LOCATION BLOCKDEV; do else DEVICE_SZ="${DEV_BYTES}B" fi - echo "${LOCATION} ${BLOCKDEV} ${DEVICE_SZ} ${DEVICE_ID}" | sed 's|/| |g' >> /tmp/bdmap + echo "${DEV_HCIL} ${DEV_PORT} ${BLOCKDEV} ${DEVICE_SZ} ${DEVICE_ID}" >> /tmp/bdmap done -column -t -R2,4 -o" " /tmp/bdmap +column -N H:C:I:L,PORT,DEV,SIZE,NAME -t -R2,4 -o" " /tmp/bdmap rm /tmp/bdmap