Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to grep the exact string / word ? Post 302656581 by ygemici on Friday 15th of June 2012 02:49:14 AM
Old 06-15-2012
Code:
# awk 'BEGIN{x="meta#";s=7}{if($0~x){if($0~x s"$")sc++;if($0~x s s"$")ssc++;if($0~x s s s"$")sssc++}}
END{print x " counts -> " sc"(" x s")",ssc"(" x s s")",sssc"(" x s s s")"}' infile
meta# counts -> 1(meta#7) 1(meta#77) 6(meta#777)

This User Gave Thanks to ygemici For This Post:
 

10 More Discussions You Might Find Interesting

1. Linux

option of grep for counting exact word ??

Hi All, I have a quary regarding grep command in linux. I have a file which contains 56677 56677 +56677 +56677 56677 56677 56677 I want to extract total count of "56677" When I hit the following command #cat filename | grep -w -c '56677' the result comes 7. Its counting... (3 Replies)
Discussion started by: maddy
3 Replies

2. UNIX for Dummies Questions & Answers

exact string match in a word

Hi all, Is anyone able to help with the following query? I have an input file with several lines of words, e.g. "hellolaylahello" "hellohellohellolayla" I want to search for the exact string "hello" in each line and display: 2 "hellolaylahello" 3 "hellohellohellolayla" I... (11 Replies)
Discussion started by: dr_sabz
11 Replies

3. Shell Programming and Scripting

How to use grep to get an exact string?

Hi there, I've search this forum and find this problem could have been solved by, grep -ho "num=*" input_data The input_data is, 1\11\num1=100\num2=200\newnum1=220\\@ however, what I have got is , num1=100 num1=220 how to get the exact string, (4 Replies)
Discussion started by: liuzhencc
4 Replies

4. Shell Programming and Scripting

QUESTION1: grep only exact string. QUESTION2: find and replace only exact value with sed

QUESTION1: How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed. Contents of car.txt CAR1_KEY0 CAR1_KEY1 CAR2_KEY0 CAR2_KEY1 CAR1_KEY10 CURRENT COMMAND LINE: WHERE VARIABLE CAR_NUMBER=1 AND KEY_NUMBER=1 grep... (1 Reply)
Discussion started by: thibodc
1 Replies

5. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

6. Shell Programming and Scripting

Grep Exact word

This may be stupid question but not able to solve it. How to grep exact word and line along with it. TEST:/u00/app/oracle/product/10.2.0/TEST:N TEST2:/u00/app/oracle/product/10.2.0/ODS:N TEST3:/u00/app/oracle/product/10.2.0/TEST:N TEST4:/u00/app/oracle/product/10.2.0/ODS:N... (4 Replies)
Discussion started by: tapia
4 Replies

7. Shell Programming and Scripting

Grep exact string from main string

Hi , am getting output file, it sontains the below values. ./hawk_DOM1_FIRST_ENV ./hawk_DOM2_SECOND_ENV ./hawk_DOM3_THIRD_ENV Now I need to grep the word "DOM1_FIRST_ENV","DOM2_SECOND_ENV" like that. I tired with cut -d "_". Its not working with any deleimiter. Can you please help to... (3 Replies)
Discussion started by: ckchelladurai
3 Replies

8. Shell Programming and Scripting

Grep to find an exact string

Hi all, I tried searching the forum for this, and I read numerous suggestions here and even on other forums, and I cannot get this to want the way that I need it to. I tried grep -W / -f to no luck. Here is what I have. I have a list of file names- FILE1-FILE1TEST,FILE1RELATION... (7 Replies)
Discussion started by: jeffs42885
7 Replies

9. UNIX for Beginners Questions & Answers

Grep multiple exact word

Hi I am trying to grep multiple exact word from log file and directing it to a new file. however my log file has many numeric values, such as 0400, 0401, 0404 and all html error also starts with 404, 401 etc so I just want to grep only when 404, 401 etc is coming, NOT 0400, OR 0401 i have... (8 Replies)
Discussion started by: scazed
8 Replies

10. Shell Programming and Scripting

Grep exact math word

Hi All, i want exact math to search to find it and i tried as like below it not working. My Excepted out : should not get the output that mean exact word math. echo "test.txt|123"|sed 's/|/ /g'|grep -w "test" Thanks (1 Reply)
Discussion started by: bmk123
1 Replies
MooseX::ClassAttribute::Trait::Class(3) 		User Contributed Perl Documentation		   MooseX::ClassAttribute::Trait::Class(3)

NAME
MooseX::ClassAttribute::Trait::Class - A trait for classes with class attributes VERSION
version 0.26 SYNOPSIS
for my $attr ( HasClassAttributes->meta()->get_all_class_attributes() ) { print $attr->name(); } DESCRIPTION
This role adds awareness of class attributes to a metaclass object. It provides a set of introspection methods that largely parallel the existing attribute methods, except they operate on class attributes. METHODS
Every method provided by this role has an analogous method in "Class::MOP::Class" or "Moose::Meta::Class" for regular attributes. $meta->has_class_attribute($name) $meta->get_class_attribute($name) $meta->get_class_attribute_list() These methods operate on the current metaclass only. $meta->add_class_attribute(...) This accepts the same options as the Moose::Meta::Attribute "add_attribute()" method. However, if an attribute is specified as "required" an error will be thrown. $meta->remove_class_attribute($name) If the named class attribute exists, it is removed from the class, along with its accessor methods. $meta->get_all_class_attributes() This method returns a list of attribute objects for the class and all its parent classes. $meta->find_class_attribute_by_name($name) This method looks at the class and all its parent classes for the named class attribute. $meta->get_class_attribute_value($name) $meta->set_class_attribute_value($name, $value) $meta->set_class_attribute_value($name) $meta->clear_class_attribute_value($name) These methods operate on the storage for class attribute values, which is attached to the metaclass object. There's really no good reason for you to call these methods unless you're doing some deep hacking. They are named as public methods solely because they are used by other meta roles and classes in this distribution. BUGS
See MooseX::ClassAttribute for details. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT AND LICENSE
This software is Copyright (c) 2011 by Dave Rolsky. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible) perl v5.16.2 2011-06-05 MooseX::ClassAttribute::Trait::Class(3)
All times are GMT -4. The time now is 08:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy