Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Grep to find lines matching given patern in a file Post 302801625 by Siva SQL on Thursday 2nd of May 2013 10:54:21 AM
Old 05-02-2013
HP Grep to find lines matching given patern in a file

When I try with patern matching in a file with below code works

Code:
cat scj_drive_commands | egrep '/app/oracle/build_lib/pkg32|/app/oracle/build_lib/pkg33'


But when I have code with patern searching using of below does not work !

Code:
cat scj_drive_commands | egrep '/app/oracle/build_lib/pkg32*2012*|/app/oracle/build_lib/pkg33*2012*'

The sample file will look like;
Code:
# == Regular Build == Pre-processing
/app/oracle/build_lib/pkg320.0_20120927/ddl/scj_build_pre_rt.sh SID TEST_NUM 20120927 320.0 N N
# == Regular Build == Processing
/app/oracle/build_lib/pkg320.0_20120927/ddl/scj_build.sh SID TEST_NUM 20120927 320.0 N Y

# == Regular Build == Pre-processing - PROFIT!!!! - change goes into DEC MR pkg313
#/app/oracle/build_lib/pkg320.0_20121004_prof/ddl/scj_build_pre_rt.sh SID TEST_NUM 20121004_prof 320.0 N N

# == Regular Build == Pre-processing
/app/oracle/build_lib/pkg320.0_20121004/ddl/scj_build_pre_rt.sh SID TEST_NUM 20121004 320.0 N N
# == Regular Build == Processing
/app/oracle/build_lib/pkg320.0_20121004/ddl/scj_build.sh SID TEST_NUM 20121004 320.0 N Y

# == Regular Build == Pre-processing
/app/oracle/build_lib/pkg320.0_20121011/ddl/scj_build_pre_rt.sh SID TEST_NUM 20121011 320.0 N N
# == Regular Build == Processing
/app/oracle/build_lib/pkg330.0_20121011/ddl/scj_build.sh SID TEST_NUM 20121011 320.0 N Y

# == Regular Build == Pre-processing
/app/oracle/build_lib/pkg330.0_20121018/ddl/scj_build_pre_rt.sh SID TEST_NUM 20121018 320.0 N N
# == Regular Build == Processing
/app/oracle/build_lib/pkg330.0_20121018/ddl/scj_build.sh SID TEST_NUM 20121018 320.0 N Y

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find matching lines between 2 files

How do I find matching lines between two files? (5 Replies)
Discussion started by: jojojmac5
5 Replies

2. Shell Programming and Scripting

find out line number of matching string using grep

Hi all, I want to display line number for matching string in a file. can anyone please help me. I used grep -n "ABC" file so it displays 6 ABC. But i only want to have line number,i don't want that it should prefix matching context with line number. Actually my original... (10 Replies)
Discussion started by: sarbjit
10 Replies

3. Shell Programming and Scripting

AIX equivalent to GNU grep's -B and -A [print lines after or before matching lines]

Hi folks I am not allowed to install GNU grep on AIX. Here my code excerpt: grep_fatal () { /usr/sfw/bin/gegrep -B4 -A2 "FATAL|QUEUE|SIGHUP" } Howto the same on AIX based machine? from manual GNU grep ‘--after-context=num’ Print num lines of trailing context after... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

4. Shell Programming and Scripting

Finding lines matching the Pattern and their previous lines in a file

Hi, I am trying to locate the occurences of certain pattern like 'Possible network disconnect' in a text file. I can get the actual lines matching the pttern using: grep -w 'Possible network disconnect' file_name. But I am more interested in getting the timing of these events which are... (7 Replies)
Discussion started by: sagarparadkar
7 Replies

5. Shell Programming and Scripting

Perl XML, find matching condition and grep lines and put the lines somewhere else

Hi, my xml files looks something like this <Instance Name="New York"> <Description></Description> <Instance Name="A"> <Description></Description> <PropertyValue Key="false" Name="Building A" /> </Instance> <Instance Name="B"> ... (4 Replies)
Discussion started by: tententen
4 Replies

6. Shell Programming and Scripting

Find the position of lines matching string

I have a file with the below format, GS*8***** ST*1******** A* B* E* RMR*123455(This is the unique number to locate this row) F* SE*1*** GE** GS*9***** ST*2 H* J* RMR*567889(This is the unique number to locate this row) L* SE* GE***** (16 Replies)
Discussion started by: Muthuraj K
16 Replies

7. Shell Programming and Scripting

Grep the non-matching lines

Hi, I need to make a script to extract the number that are not in a file. Example: I have file-A that has 100000 (70000-799999) numbers. And a file-B with number that already are in the system. Now I need to know/get the numbers that are not in system. I was thinking something like this:... (5 Replies)
Discussion started by: AK47
5 Replies

8. UNIX for Dummies Questions & Answers

Grep to find matching patern and return unique values

Request: grep to find given matching patern and return unique values, eliminate the duplicate values I have to retrieve the unique folder on the below file contents like; /app/oracle/build_lib/pkg320.0_20120927 /app/oracle/build_lib/pkg320.0_20121004_prof... (5 Replies)
Discussion started by: Siva SQL
5 Replies

9. UNIX for Dummies Questions & Answers

FIND matching pattern of lines in a file

I need to search for two patterns in a file and find number of matching lines. find . -type f | xargs grep "DROP TABLE" | wc -l find . -type f | xargs grep "DROP SYNONYM" | wc -l The above code works. However I am looking at finding a commnd that will simplify as on a singe command... (2 Replies)
Discussion started by: Siva SQL
2 Replies

10. Shell Programming and Scripting

How to print few lines before and after matching word is found suing grep?

Hi, here are few lines present in the logs. I want to grep on Error and print few lines before and after Error word is found line1 Line2 Line3 Error Line4 Line5 Line6 Line7 I want the output to be Line2 Line3 Error Line5 (1 Reply)
Discussion started by: arghadeep adity
1 Replies
TNTNET-CONFIG(1)					      General Commands Manual						  TNTNET-CONFIG(1)

NAME
tntnet-config - output compiler flags for tntnet usage SYNOPSIS
tntnet-config [--libs] [--cxxflags] [--config[=app]] [--makefile[=app]] [--project=app] [--autoproject=app] [--help] [--version] DESCRIPTION
This manual page documents briefly the tntnet-config command. OPTIONS
This program's options start with two dashes (`-'). A summary of options is included below. --libs Output linker flags. --cxxflags Output C++ preprocessor and compiler flags. --config[=app] Print default configuration file. --makefile[=app] Print a simple makefile for an ecpp project. --project=app Create a simple ecpp project directory. --autoproject=app Create a autotools based ecpp project. --help Show summary of options. --version Show version of program. AUTHOR
tntnet was written by Tommi Makitalo <tommi@tntnet.org>. This manual page was written by Kari Pahula <kaol@debian.org>, for the Debian project (but may be used by others). SEE ALSO
tntnet(8), ecppc(1), ecppl(1), ecppll(1). More documentation can be found in /usr/share/doc/tntnet-doc/. July 3, 2006 TNTNET-CONFIG(1)
All times are GMT -4. The time now is 02:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy