Sponsored Content
Full Discussion: Search for exact string
Top Forums Shell Programming and Scripting Search for exact string Post 302377635 by rahman_riyaz on Friday 4th of December 2009 01:45:46 PM
Old 12-04-2009
Thanks for the feedback.

I tried the mentioend commands it does not work .

In the meain while i tried

abc_var= echo "${abc_var}"| sed -e s/\"/\\\\\"/g

is_there=cat test.dat |awk 'BEGIN {FS=",";i=0} {if ( $1 == "${abc_var}" ) {i=i+1}} END'


But this prints the cat output on console . test.dat is huge so it does not look good.

Any suggestions will be welcome.

Thanks in anticipation.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do I search a File for a string exact match

Hi, Can you help please. I have the following comand: if ]; then l_valid_string="Y" fi The problem I am trying to solve is that my l_string = ABC and my file contains ABC ABC_EFG I only want back the value ABC exact match. (3 Replies)
Discussion started by: CAGIRL
3 Replies

2. UNIX for Dummies Questions & Answers

grep exact string/ avoid substring search

Hi All, I have 2 programs running by the following names: a_testloop.sh testloop.sh I read these programs names from a file and store each of them into a variable called $program. On the completion of the above programs i should send an email. When i use grep with ps to see if any of... (3 Replies)
Discussion started by: albertashish
3 Replies

3. Shell Programming and Scripting

exact string match ; search and print match

I am trying to match a pattern exactly in a shell script. I have tried two methods awk '/\<mpath${CURR_MP}\>/{print $1 $2}' multipath perl -ne '/\bmpath${CURR_MP}\b/ and print' /var/tmp/multipath Both these methods require that I use the escape character. I am guessing that is why... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies

4. UNIX for Advanced & Expert Users

Search for an exact string in a Terminal

Is there hopefully a way to search for an exact string in Man Pages? I know if I want to search for anything containing -c I can just do this. /-c How would I search for "-c"? I want only "-c" to show up. So I tried this. /"-c" It took me literally and looked for the quotes also. (13 Replies)
Discussion started by: cokedude
13 Replies

5. Shell Programming and Scripting

search and replace exact string

Hello Everyone, Im trying to run a search and replace of exact strings and the strings that im using variables that are passed through an array in a while loop. Here is a snip of my code: USEROLD=`cat oldusers` USERNEW=`cat newusers` USEROLDARRAY=( $USEROLD ) USERNEWARRAY=( $USERNEW )... (4 Replies)
Discussion started by: skizim
4 Replies

6. Shell Programming and Scripting

How to use SED or AWK to search and replace an exact string

I have a file DS1 DDS DS I want to replace only "DS" to "DSmail.blah.com" in a lot of files. I tried sed 's/DS/DSmail.blah.com' but it changes all the lines . thanks in advance (2 Replies)
Discussion started by: gubbu
2 Replies

7. 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

8. 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

9. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

10. Shell Programming and Scripting

Search string within a file and list common words from the line having the search string

Hi, Need your help for this scripting issue I have. I am not really good at this, so seeking your help. I have a file looking similar to this: Hello, i am human and name=ABCD. How are you? Hello, i am human and name=PQRS. I am good. Hello, i am human and name=ABCD. Good bye. Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies
OpenGuides::Search(3pm) 				User Contributed Perl Documentation				   OpenGuides::Search(3pm)

NAME
OpenGuides::Search - Search form generation and processing for OpenGuides. DESCRIPTION
Does search stuff for OpenGuides. Distributed and installed as part of the OpenGuides project, not intended for independent installation. This documentation is probably only useful to OpenGuides developers. SYNOPSIS
use CGI; use OpenGuides::Config; use OpenGuides::Search; my $config = OpenGuides::Config->new( file => "wiki.conf" ); my $search = OpenGuides::Search->new( config => $config ); my %vars = CGI::Vars(); $search->run( vars => \%vars ); METHODS
new my $config = OpenGuides::Config->new( file => "wiki.conf" ); my $search = OpenGuides::Search->new( config => $config ); wiki my $wiki = $search->wiki; An accessor; returns the underlying Wiki::Toolkit object. config my $config = $search->config; An accessor; returns the underlying OpenGuides::Config object. run my %vars = CGI::Vars(); $search->run( vars => \%vars, return_output => 1, # defaults to 0 return_tt_vars => 1, # defaults to 0 ); The "return_output" parameter is optional. If supplied and true, the stuff that would normally be printed to STDOUT will be returned as a string instead. The "return_tt_vars" parameter is also optional. If supplied and true, the template is not processed and the variables that would have been passed to it are returned as a hash. This parameter takes precedence over "return_output". These two parameters exist to make testing easier; you probably don't want to use them in production. You can also request just the raw search results: my %results = $search->run( os_x => 528864, os_y => 180797, os_dist => 750, format => "raw", ); Results are returned as a hash, keyed on the page name. All results are returned, not just the first "page". The values in the hash are hashes themselves, with the following key/value pairs: o name o wgs84_lat - WGS-84 latitude o wgs84_long - WGS-84 longitude o summary o distance - distance (in metres) from origin, if origin exists o score - relevance to search string, if search string exists; higher score means more relevance In case you're struggling to follow the code, it does the following: 1) Processes the parameters, and bails out if it hit a problem with them 2) If a search string was given, do a text search 3) If distance search paramaters were given, do a distance search 4) If no search has occured, print out the search form 5) If an error occured, bail out 6) If we got a single hit on a string search, redirect to it 7) If no results were found, give an empty search results page 8) Sort the results by either score or distance 9) Decide which results to show, based on paging 10) Display the appropriate page of the results INPUT
word a single word will be matched as-is. For example, a search on escalator will return all pages containing the word "escalator". AND searches A list of words with no punctuation will be ANDed, for example: restaurant vegetarian will return all pages containing both the word "restaurant" and the word "vegetarian". OR searches A list of words separated by commas (and optional spaces) will be ORed, for example: restaurant, cafe will return all pages containing either the word "restaurant" or the word "cafe". phrase searches Enclose phrases in double quotes, for example: "meat pie" will return all pages that contain the exact phrase "meat pie" - not pages that only contain, for example, "apple pie and meat sausage". SEARCHING BY DISTANCE
To perform a distance search, you need to supply one of the following sets of criteria to specify the distance to search within, and the origin (centre) of the search: os_dist, os_x, and os_y Only works if you chose to use British National Grid in wiki.conf osie_dist, osie_x, and osie_y Only works if you chose to use Irish National Grid in wiki.conf latlong_dist, latitude, and longitude Should always work, but has a habit of "finding" things a couple of metres away from themselves. You can perform both pure distance searches and distance searches in combination with text searches. OUTPUT
Results will be put into some form of relevance ordering. These are the rules we have tests for so far (and hence the only rules that can be relied on): o A match on page title will score higher than a match on page category or locale. o A match on page category or locale will score higher than a match on page content. o Two matches in the title beats one match in the title and one in the content. AUTHOR
The OpenGuides Project (openguides-dev@lists.openguides.org) COPYRIGHT
Copyright (C) 2003-2008 The OpenGuides Project. All Rights Reserved. The OpenGuides distribution is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
OpenGuides perl v5.14.2 2013-01-11 OpenGuides::Search(3pm)
All times are GMT -4. The time now is 05:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy