first of all, $objtype is the target to compile for, not the type of the local cpu. You at least need to look at $cputype. The following would do it with one less process: sed -n 's/^O=(.*)/\1/p' /$cputype/mkfile