b1.csv name zhangsan lisi aa.csv name zhangsan wangsi check_names <- function(file) { require(readr) check_file <- readr::read_delim(file=file,delim=" ", col_names = c("name")) aa <- readr::read_delim(file="/home/work/blue/aa.csv",delim=" ", col_names = c("name")) ret <- intersect(aa, check_file) ret } file = "/home/work/blue/b1.csv" abc <- check_names(file) abc