Skip to content

Instantly share code, notes, and snippets.

@Chunlin-Li
Last active March 9, 2016 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chunlin-Li/1cc5b6f6868f43f8da52 to your computer and use it in GitHub Desktop.
Save Chunlin-Li/1cc5b6f6868f43f8da52 to your computer and use it in GitHub Desktop.
用 awk 判断文件2中的行是否在文件1中都存在.
{
  if(FNR==NR) { # first file
        map[$1]=1
  } else {  # second file
        if ($1 in map) {
        } else {
            print $1
        }
  }
}

# awk -f this.awk file1 file2 
# 输出所有 file2 中存在, 但 file1 中不存在的行.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment