Need the following output
ONGC044
ONGC043
ONGC042
ONGC041
ONGC046
ONGC047
from this input
Medium Label Medium ID Free Blocks
===============================================================================
[ONGC044] ECCPRDDB_FS_43 ac100076:4aed9b39:44f0:0001 195311616
[ONGC043] ECCPRDDB_FS_42 ac100076:4aed9b1d:44e8:0001 195311616
[ONGC042] ECCPRDDB_FS_41 ac100076:4aed9af4:4469:0001 195311616
[ONGC041] ECCPRDDB_FS_40 ac100076:4aed9ad3:445e:0001 195311616
[ONGC046] ECCPRDDB_FS_44 ac100076:4aedd04a:68c6:0001 195311616
[ONGC047] ECCPRDDB_FS_45 ac100076:4aedd4a0:6bf5:0001 195311616
awk -F"[][]" 'NR>2{print $2}' file
I think what you want is:
awk '/^\[.*\]/ {print substr($1,2,7)}' < ~/tmp/awk_test/file
This assumes that your first field is exactly 9 (7 of them are the ones you want) characters each time. If this is not the case, then use the following instead to strip off of the [ and the ] from the first field:
awk '/^\[.*\]/ {gsub(/[\[\]]/,"",$1); print $1 }' < ~/tmp/awk_test/file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With