BEGIN{ } { ++ids[$1]; } END{ for ( key in ids ) { print(key) > "/tmp/test/uniq.txt" } }