remove everything after last instance of character
# Removes everything after the "." # You could subsitute "." for anything (i.e., "_", "/") awk 'BEGIN{FS=OFS="."} NF--' FILE