grep -c "" <file>
2011年10月12日 星期三
2011年10月10日 星期一
Split files according to index
Suppose I have a csv file like this:
27, california , A3
27, vermont, B6
27, ontario, B7
34, kansas, C9
34, washington, A2
How do I split this file into two files according to field1.
file1:
27, california , A3
27, vermont, B6
27, ontario, B7
file2:
34, kansas, C9
34, washington, A2
awk -F"," ' { print > "file"$1 } ' filename
27, california , A3
27, vermont, B6
27, ontario, B7
34, kansas, C9
34, washington, A2
How do I split this file into two files according to field1.
file1:
27, california , A3
27, vermont, B6
27, ontario, B7
file2:
34, kansas, C9
34, washington, A2
awk -F"," ' { print > "file"$1 } ' filename
display only first few several lines from file Linux UNIX command
let say i only want to show the first six lines, then i would use this command
head -6 users.txt
head -6 users.txt
awk command to merge columns from two separate files into single file
> cat file1
one two three
one two three
one two three
one two three
> cat file2
four five six
four five six
four five six
four five six
> pr -m -t -s file1 file2 | gawk '{print $4,$5,$6,$1}'
four five six one
four five six one
four five six one
four five six one
one two three
one two three
one two three
one two three
> cat file2
four five six
four five six
four five six
four five six
> pr -m -t -s file1 file2 | gawk '{print $4,$5,$6,$1}'
four five six one
four five six one
four five six one
four five six one
訂閱:
文章 (Atom)