Posted on 01-29-2014 05:18 AM
I am trying to clean up the results that report back on my EA. I am sure this is something simple but my eyes are getting cross-eyed trying to get the correct syntax.
I have an EA that reports back the board-id of the systems.
echo "<result>$(ioreg -p "IODeviceTree" -r -n / -d 1 | grep "board-id")</result>"
reports back "board-id" = <"Mac-6F01561E16C75D06">
To delete the "board-id" = I added the | awk '{print $3}'
echo "<result>$(ioreg -p "IODeviceTree" -r -n / -d 1 | grep "board-id" **| awk '{print $3}'**)</result>"
reports back **<"**Mac-6F01561E16C75D06**">**
To delete the "" I added the | sed s/"//g
echo "<result>$(ioreg -p "IODeviceTree" -r -n / -d 1 | grep "board-id" | awk '{print $3}' **| sed s/"//g)**</result>"
reports back **<**Mac-6F01561E16C75D06**>**
To delete the < I added the | sed s/<//g
echo "<result>$(ioreg -p "IODeviceTree" -r -n / -d 1 | grep "board-id" | awk '{print $3}' **| sed s/<//g**)</result>"
reports back **"**Mac-6F01561E16C75D06**">**
To delete the < & " I added the | sed s/<"//g
echo "<result>$(ioreg -p "IODeviceTree" -r -n / -d 1 | grep "board-id" | awk '{print $3}' **| sed s/<"//g**)</result>"
reports back Mac-6F01561E16C75D06**">**
I cannot get the syntax correct to report without <" & ">
What I want it to report back is Mac-6F01561E16C75D06
Solved! Go to Solution.
Posted on 01-29-2014 05:43 AM
Have you considered replacing awk with the only true script language?
ioreg -p "IODeviceTree" -r -n / -d 1 |
perl -n -e '/board-id.*<"(.*)">.*/ && print "<result>$1</result>
"'
HTH?
Marko
Posted on 01-29-2014 05:43 AM
Have you considered replacing awk with the only true script language?
ioreg -p "IODeviceTree" -r -n / -d 1 |
perl -n -e '/board-id.*<"(.*)">.*/ && print "<result>$1</result>
"'
HTH?
Marko
Posted on 01-29-2014 06:53 AM
Thanks Marko, you are the best.
Posted on 01-29-2014 06:54 AM
Or, you could stick with awk and use awk's special multi character field separator in combination with its regex matching to print only the text between the second set of "s
echo "<result>$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'["|"]' '/board-id/{print $4}')</result>"
<result>Mac-94245B3640C91C81</result>
Posted on 01-29-2014 06:55 AM
Dreaded double post...
Posted on 01-29-2014 10:38 AM
I got it working by substituting sed with tr
$ ioreg -p "IODeviceTree" -r -n / -d 1 | grep "board-id" | awk '{print $3}'| tr -d "<>