sed

Text processing with awk sed and cut

awk sed and cut - tools to process text data in Linux OS

Sam
awk openstack image list > images.txt +----------------+--------------+-----------+ | ID | Name | Status | +----------------+--------------+-----------+ | 9789-4b3f-95b8 | windows-2012 | active | | 27a3-46c2-b821 | windows-2016 | active | | f45a-4c89-a69f | windows-2019 | active | | 012f-4751-822a | windows-2019 | active | | 68c8-4d4b-a5b5 | windows-2022 | active | +----------------+--------------+-----------+ extract only windows-2016 image id # on a bash or zsh shell ID=`awk '$4=="windows-2016" {print $2}' images.txt` echo $ID 27a3-46c2-b821 # on a fish shell set ID $(awk '$4=="windows-2016" {print $2}' images.