#!/bin/bash # # Assuming the notes field of a host.cfg file is "notes\s " then print them out files="" while [ -n "$1" ]; do case "$1" in -f|--file) files="$2"; shift 2;; *) shift 1;; esac done for file in `egrep -l notes $files`; do awk '/host_name/ {host=$2}; /notes/ {lat=$2; lon=$3} END {print host, lat, lon}' $file done