Computer Science
General Computer Science articles :)
Tuesday, February 17, 2009
Counting the occurance of a string in a file
The following counts the number of lines the occurrence of the word "test" occurs in a file:
grep -c " test " filename
Counting all occurrences:
grep -o " test " filename | wc -w
Friday, February 6, 2009
Removing duplicate lines from a file using awk
awk '!($0 in a) {a[$0];print}' infile > outfile
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)