白名单:过滤文件中指定userid的数据 #61
guodongxiaren
started this conversation in
教程
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
问题
一个CSV文件TAB分割,假设名为data.txt,第二列是userid。
另外有一个文件是userid的文件,假设名为userid.txt。每一行都是一个userid。
过滤data.txt,找到userid.txt中的userid的数据来输出。
一行awk解法
解读
BEGIN是在awk循环解析之前都初始化阶段。
a[$1]=1
建立关联数组,userid.txt里的每个userid为key,value为1。Beta Was this translation helpful? Give feedback.
All reactions