2011年3月3日星期四

extract columns from or subset by columns of a big file

here two means:

(1). cut
# extract several columns from a tab-delimited file
# You can try to place a tab between the quotes if you first press " v" then the "" key:
cut -f 1-10 -d "v "

# extract column 1 and column 3 from big_file to a subset_file
cat big_file | cut -f 1,3 -d " " > subset_file

(2). awk
# extract column 1 and 3 with all cell including M of big_file to subset_file
cat Agu-1_fv.txt | grep M | awk '{ print $1, $3}' > subset_file

没有评论:

发表评论