Closed sscargal closed 2 years ago
The following awk script will reformat the data to the requested output format
# AWK rules explanation
#
# Change the Output Field Separator to the '|' symbol
# BEGIN {OFS="|"}
#
# For all rows that do not begin with '---', remove all leading and trailing white spaces, then print the HdrValue and Fields 1 and 2, then move to the next row
# Performing this row first avoids unnecessary test conditions if we were to place this rule later in the order
# $0 !~ /^---/ {gsub(/^[ \t]+|[ \t]+$/, "", $0);print HdrValue,$1,$2; next}
#
# For rows that begin with '---', replace '---' with blanks, then set HdrStr to Field 1 and HdrValue to Field 2
# $0 ~ /^---/ {gsub(/\-/, "", $0); HdrStr=$1; HdrValue=$2;}
#
# Print the output Header if processing the first row in the input file
# NR == 1 {print HdrStr"|Property|Value";}
awk -F '[=]' 'BEGIN {OFS="|"}
$0 !~ /^---/ {gsub(/^[ \t]+|[ \t]+$/, "", $0);print HdrValue,$1,$2; next}
$0 ~ /^---/ {gsub(/\-/, "", $0); HdrStr=$1; HdrValue=$2;}
NR == 1 {print HdrStr"|Property|Value";}
' ipmctl_show_-a_-dimm
Fixed by #51
The non-all (-a) outputs from
ipmctl
are displayed in a pipe separated value table format, eg:When adding the all (-a) option, the output format is different, eg:
To make the rules easier to implement and consistent, the output from the 'all' command should be reformatted into the pipe-separated value table format.