#!/usr/bin/gawk -f BEGIN { OFS = "\t"; } ($1 ~ /^B-/) { getline label < labFN; $1 = "B-" label; } ($1 ~ /^I-/) { $1 = "I-" label; } { print }