Hi ,
I am using SUN OS Version 5.6.
I have a file that contains records of length 270. when I do 'set nu' in vi editor, I get the count as 86. whereas when I do "wc -l" on the command prompt, it shows the count as only 85. this is very strange. why would the 'wc' show 1 record less. The job... (3 Replies)
Hi all,
I have a pattern like this in a file:
123 4 56 789
234 5 67 789
121 3 56 789
222 4 65 789
321 6 90 100
478 8 40 789
243 7 80 789
How can I count the number of occurences of '789' (4th column) in this set...?
Thanks for all your help!
K (7 Replies)
Hi all
Can anybody suggest me, how to get the count of digits in a word
I tried
WORD=abcd1234
echo $WORD | grep -oE ] | wc -l
4
It works in bash command line, but not in scripts :mad: (12 Replies)
I am a newbie in UNIX shell script and seeking help on this UNIX function. Please give me a hand. Thanks.
I have a large file. Named as 'MyFile'. It was tab-delmited. I am told to write a shell function that counts the number of occurrences of the ord “mysring” in the file 'MyFile'. (1 Reply)
im trying to count the number of occurences of column 2 value(starting from KKK*) of the below file, file.txt
using the code cat file.txt | awk ' BEGIN { print "Category Counts"} {FS=","} {NR > 2} { cats = cats + 1} END { for(c in cats) { print c, "=", cats} } '
but its returning as
... (6 Replies)
Hello world,
Can anybody tell me how to count how many times does a word repeat in a file? There have been many threads on this but they all are heavy loads of Scripting for a starter like me. :D
So, I sat down today and after some hours of reading man pages, I found a simple one-line... (18 Replies)
Hi Guys,
I have 2 files like below
file1
xx
yy
file2
b
yy
b2
xx
c1
yy
xx
yy
Now I want an idea which can count occurences of text from file1 and file2 so outbout would be kind of (9 Replies)
I have some files as shown below
GLL ALM 654-656 654 656
SEM LYG 655-657 655 657
SEM LYG 655-657 655 657
ALM LEG 656-658 656 658
ALM LEG 656-658 656 658
ALM LEG 656-658 656 658
LEG LEG 658-660 658 660
LEG LEG 658-660 658 660 The value of GLL is... (5 Replies)
Hi, I would like to count the number of ALA occurences without having them to be repeated. In the script I have written now it has 40 repetitions of ALA but it has to be 8. ALA is chosen as one of the 20 values it can have when the script asks for the input of AAA, which for this example is chosen... (7 Replies)
Discussion started by: Aurimas
7 Replies
LEARN ABOUT DEBIAN
stag-grep
STAG-GREP(1p) User Contributed Perl Documentation STAG-GREP(1p)NAME
stag-grep - filters a stag file (xml, itext, sxpr) for nodes of interest
SYNOPSIS
stag-grep person -q name=fred file1.xml
stag-grep person 'sub {shift->get_name =~ /^A*/}' file1.xml
stag-grep -p My::Foo -w sxpr record 'sub{..}' file2
USAGE
stag-grep [-p|parser PARSER] [-w|writer WRITER] NODE -q tag=val FILE
stag-grep [-p|parser PARSER] [-w|writer WRITER] NODE SUB FILE
stag-grep [-p|parser PARSER] [-w|writer WRITER] NODE -f PERLFILE FILE
DESCRIPTION
parsers an input file using the specified parser (which may be a built in stag parser, such as xml) and filters the resulting stag tree
according to a user-supplied subroutine, writing out only the nodes/elements that pass the test.
the parser is event based, so it should be able to handle large files (although if the node you parse is large, it will take up more
memory)
ARGUMENTS
-p|parser FORMAT
FORMAT is one of xml, sxpr or itext, or the name of a perl module
xml assumed as default
-w|writer FORMAT
FORMAT is one of xml, sxpr or itext, or the name of a perl module
-c|count
prints the number of nodes that pass the test
-filterfile|f
a file containing a perl subroutine (in place of the SUB argument)
-q|query TAG1=VAL1 -q|query TAG2=VAL2 ... -q|query TAGN=VALN
filters based on the field TAG
other operators can be used too - eg <, <=, etc
multiple q arguments can be passed in
for more complex operations, pass in your own subroutine, see below
SUB a perl subroutine. this subroutine is evaluated evry time NODE is encountered - the stag object for NODE is passed into the subroutine.
if the subroutine passes, the node will be passed to the writer for display
NODE
the name of the node/element we are filtering on
FILE
the file to be parser. If no parser option is supplied, this is assumed to a be a stag compatible syntax (xml, sxpr or itext);
otherwise you should parse in a parser name or a parser module that throws stag events
SEE ALSO
Data::Stag
perl v5.10.0 2008-12-23 STAG-GREP(1p)