Results 1 to 4 of 4
Hello friends.
i have a question about using awk.
for example there is a document & there are lots of xyz word in the document.
how can i count this ...
- 12-24-2009 #1Just Joined!
- Join Date
- Dec 2009
- Posts
- 1
awk question
Hello friends.
i have a question about using awk.
for example there is a document & there are lots of xyz word in the document.
how can i count this xyz.
i want to show there are ... xyz word in this document.
- 12-24-2009 #2
Try this..
usage:
awk -f prog.awk filename
Code:#! /usr/bin/awk -f BEGIN { print("Searching for the xyz....\n"); found = 0; lines = 0; FS = ""; } { ++lines; for (i = 1; i <= NF; ++i) { ++charin; if (($i == "x") && ($(i + 1) == "y") && ($(i + 2) == "z")) { ++found; printf("found entry %d, on line %d\n", found, lines); } } } END { printf("found %d entries...\n", found); }Make mine Arch Linux
- 12-24-2009 #3Linux User
- Join Date
- Aug 2006
- Posts
- 458
Code:awk ' {m=gsub(/xyz/,"") ;t+=m} END{print t}' file
- 12-25-2009 #4Just Joined!
- Join Date
- Dec 2009
- Posts
- 1
Compare two text files
Hai guys i have one question
i have two files
cat > file1
9842121,a4
9942121,a4
9742121,a4
cat > file2
9842121,a4
9742121,a4
9442121,a4
iwant output like below
9842121,a4
basicallly i wnat to compare two text files first column and if it is same the i would print it in a new text file
can anybody help me out please


Reply With Quote