The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > The UNIX Forums - Contact Us > Post Here to Contact Site Administrators and Moderators
Google UNIX.COM


Post Here to Contact Site Administrators and Moderators Make Suggestions About Forums, Features, or Content here. Discuss Rules and Guidelines. Get Forum Support Here. (Registered Users Only)

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
search excat string in another string (grep "fails") bora99 UNIX for Dummies Questions & Answers 0 06-05-2008 03:41 AM
Search, replace string in file1 with string from (lookup table) file2? gstuart Shell Programming and Scripting 2 04-11-2008 11:32 AM
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 06:24 AM
Search for a string sumesh.abraham Shell Programming and Scripting 12 12-11-2006 05:29 AM
appending string to text file based on search string malaymaru Shell Programming and Scripting 1 06-09-2006 05:53 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-13-2008
Registered User
 

Join Date: Feb 2008
Posts: 1
Search String

Hi I have a file with multiple fields,

I want to search for two strings "DONOTUSE" and "DO NOT USE" from the first field.

Cand anyone help me how to do this...

Thnks,
Ajith
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-13-2008
joeyg's Avatar
premier etoile de match
 

Join Date: Dec 2007
Location: Home of world champion Boston Celtics
Posts: 511
Cool

Here is a sample script. It checks for the existence of one of two five-character strings to match. If found on a line, will echo the line to the screen (you can do whatever you want with the echo). Also, I am setting the lines (al_pr1 & al_pr2) separately since it is unclear to me exactly how you want to match. (You mention field 1, but without a sample file it is difficult to determine how to define/match your first field. Lastly, I use in my sample the file called alarms, but you can use anything you want at that point.


#! /bin/bash

al_fl1="MULCT"
al_fl2="JUNCT"
while read alt
do
al_pr1=$(echo $alt | grep $al_fl1)
al_pr2=$(echo $alt | grep $al_fl2)
if [ -n al_pr1 -o -n al_pr2 ]
then
echo "$alt"
fi
done < alarms
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0