Issue
I run a CLI command that outputs various database values. One CLI command example is:
show attributes attr=0x1006e mh=0x12003ea | awk '{print substr($0, 68)}' | grep -v Value
The output looks like this:
Secure Domain
So this technique definitely works.
Without the awk command, and subsequent "grep -v Value" command the output looks like this:
Id Name Iid Value
0x1006e Model_Name_Attr Secure Domain
Where Id=0x1006e, Name=Model_Name_Attr, Iid=Blank column, Value=Secure Domain
The columns don't match up in this "stackoverflow" website. sorry.
The awk command works because there are exactly 68 spaces until you reach the first word in the Value column, which is "Secure".
I can't use awk 'NR==1 {next;}; {print $3}'
because the output will simply be the word "Secure". The name has a space in between, and I need the entire Value of Secure Domain
.
I tried various iterations of awk and cannot find a solution.
Solution
Remove the first two fields from the line, then print the rest of the line.
show attributes attr=0x1006e mh=0x12003ea | awk 'NR > 1 {$1 = $2 = ""; sub(/^ +/, ""); print}'
Answered By - Barmar Answer Checked By - Mary Flores (WPSolving Volunteer)