I have a rather large config file that has server short names in it like this:[host 1]host = server1[host 2]host = server2[host 3]host = server3I need to replace all the server short names with the fq long names that will be outputted from a bash script I've already written, lookup.sh. Can I work some sed or awk magic to accomplish this task?
bash script to replace server short names in a file with fqdn
bash;shell script;sed;awk;scripting
Your question implied the use of sed or awk, but you didn't explicitly rule out perl #!/usr/bin/perlwhile (<>){    if (/^host = (.+)/) {        print host =  . `./lookup.sh $1`;    }    else {         print;    }}Upon further reflection, the same could be done in awk as follows:#!/bin/bashINFILE=$1awk 'BEGIN { FS =  =  } ; {        if ($1 == host) {                './lookup.sh ' $2 | getline fqdn                $2 = =; $3 = fqdn        }        print}' $INFILE