2012年8月23日星期四

fileter file by columns - grep


# what I want to do is: filter test file by ID file based their general columns.

jmao@upa:~$ cat ID
CA10
CA13
CA15

jmao@upa:~$ cat test
15 CA11 0 0 1 0 2 2 -9 -9 1 2 -9 -9 1 1 1 2 1
2 CA13 0 0 1 0 2 2 -9 -9 1 1 -9 -9 -9 -9 1 1 1
25 CA10 0 0 1 0 2 2 -9 -9 1 2 -9 -9 1 1 1 1 1
15 CA15 0 0 1 0 2 2 -9 -9 1 2 -9 -9 1 1 1 2 1
2 CA14 0 0 1 0 2 2 -9 -9 1 1 -9 -9 -9 -9 1 1 1
25 CA18 0 0 1 0 2 2 -9 -9 1 2 -9 -9 1 1 1 1 1

# using the Unix command, grep, we got our job done.
# be careful for -f and -F for grep command.

jmao@upa:~$ grep -Ff ID test
2 CA13 0 0 1 0 2 2 -9 -9 1 1 -9 -9 -9 -9 1 1 1
25 CA10 0 0 1 0 2 2 -9 -9 1 2 -9 -9 1 1 1 1 1
15 CA15 0 0 1 0 2 2 -9 -9 1 2 -9 -9 1 1 1 2 1
jmao@upa:~$ grep -f ID test
2 CA13 0 0 1 0 2 2 -9 -9 1 1 -9 -9 -9 -9 1 1 1
25 CA10 0 0 1 0 2 2 -9 -9 1 2 -9 -9 1 1 1 1 1
15 CA15 0 0 1 0 2 2 -9 -9 1 2 -9 -9 1 1 1 2 1

没有评论:

发表评论