I am trying to capture the last value before the the * in test4.txt file using sed & tail (in this case 0FA). I got the output using the below steps.
P.s: The number of * in the file varies from file to file.
Any idea of a better way to do this?
cat test4.txt
1234 Not Visible 0 00 046
5678 Not Visible 0 00 047 *
0123 Not Visible 0 00 0F0
0234 Not Visible 0 00 0F1
0567 Not Visible 0 00 0F2
0789 Not Visible 0 00 0F3
1256 Not Visible 0 00 0F4 *
0912 Not Visible 0 00 0F5
0546 Not Visible 0 00 0F6
0678 Not Visible 0 00 0F7
0734 Not Visible 0 00 0F8
1432 Not Visible (M) 0 00 0F9
- AVAILABLE 0 00 0FA *
Total ----
Mapped Devices: 42
Including Metamembers: 311
Available Addresses: 2612 (s)
Legend for Available address:
(*): The VBUS, TID, LUN address values represent a gap in the
address assignments or are the next available address in
the run
(s): The Available Addresses for a director are shared among
its ports (shared)
sed -n '/*/p' test4.txt >>test3.txt
tail -2 test3.txt |sed 's/.*\(....\)*.*/\1/' >> /var/tmp/test2.txt
sed '$d' lun2.txt >> /var/tmp/test1.txt
rm /var/tmp/test4.txt
rm /var/tmp/test3.txt
rm /var/tmp/test2.txt
cat test1.txt
OFA