To grep in sequence


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To grep in sequence
# 8  
Old 06-11-2009
If you have egrep you can grep for 'CRMSUB|ENTRGCSERV'.

Regards
# 9  
Old 06-11-2009
yaa

I tried this as well
egrep '^<CRMSUB|^<ENTRGCSERV' filename.txt but the thing is that the records we get in sequence of CRMSUB and ENTRGCSERV parameters.but that command line also have ENTROPRSERV parameters which is not showing by this egrep.I want command having no ENTROPRSERV parameters only first line CRMSUB and second line ENTRGCSERV and no ENTROPRSERV.am I able to explain now
# 10  
Old 06-11-2009
Post an example of your input files with more lines and the desired output within code tags (select the text and click on the # above the edit box).
# 11  
Old 06-11-2009
Hi this are format in log file
start with parameter CRMSUB

1<CRMSUB:MSIN=2200380,BSNBC=TELEPHON-7553&TS21-7716553&TS22-7716553,NDC=70,MSCAT=ORDINSUB,SUBRES=ONAOFPLM,ACCSUB=BSS,NUMTYP=SINGLE;
2<ENTROPRSERV:MSIN=22580,OPRSERV=OCSI-PPSMOC-ACT-DACT&TCSI-PPSMTC-ACT-DACT&UCSI-USSD;
3<ENTRGCSERV:MSIN=56380,GCSERV=CALLWAIT-ACT-TELEPHON&CALLHOLD&CLIP&MPTY,CLIPOVR=NO;
4<CRMSUB:MSIN=225380,BSNBC=TELEPHON-7553&TS21-7716553&TS22-7716553,NDC=70,MSCAT=ORDINSUB,SUBRES=ONAOFPLM,ACCSUB=BSS,NUMTYP=SINGLE;
5<ENTROPRSERV:MSIN=226380,OPRSERV=OCSI-PPSMOC-ACT-DACT&TCSI-PPSMTC-ACT-DACT&UCSI-USSD;
6<ENTRGCSERV:MSIN=25580,GCSERV=CALLWAIT-ACT-TELEPHON&CALLHOLD&CLIP&MPTY,CLIPOVR=NO;
7<CRMSUB:MSIN=22330,BSNBC=TELEPHON-7553&TS21-7716553&TS22-7716553,NDC=70,MSCAT=ORDINSUB,SUBRES=ONAOFPLM,ACCSUB=BSS,NUMTYP=SINGLE;
8<ENTRGCSERV:MSIN=2233380,GCSERV=CALLWAIT-ACT-TELEPHON&CALLHOLD&CLIP&MPTY,CLIPOVR=NO;
9<CRMSUB:MSIN=2200380,BSNBC=TELEPHON-7553&TS21-7716553&TS22-7716553,NDC=70,MSCAT=ORDINSUB,SUBRES=ONAOFPLM,ACCSUB=BSS,NUMTYP=SINGLE;
10<ENTROPRSERV:MSIN=23380,OPRSERV=OCSI-PPSMOC-ACT-DACT&TCSI-PPSMTC-ACT-DACT&UCSI-USSD;
11<ENTRGCSERV:MSIN=226380,GCSERV=CALLWAIT-ACT-TELEPHON&CALLHOLD&CLIP&MPTY,CLIPOVR=NO;
12<CRMSUB:MSIN=2200,BSNBC=TELEPHON-7553&TS21-7716553&TS22-7716553,NDC=70,MSCAT=ORDINSUB,SUBRES=ONAOFPLM,ACCSUB=BSS,NUMTYP=SINGLE;
13<ENTRGCSERV:MSIN=2280,GCSERV=CALLWAIT-ACT-TELEPHON&CALLHOLD&CLIP&MPTY,CLIPOVR=NO;


I have to select all records from that log file having no ENTROPRSERV parameters. like line 7-8 and 12-13
I numbered the command lines
# 12  
Old 06-11-2009
Try this:

Code:
awk '/^CRMSUB/{s=$0;getline;if(match($0,"ENTRGCSERV")){print s;print}}' file

# 13  
Old 06-12-2009
Hi I tried code on SunOS and getting mentioed error
awk '/^CRMSUB/{s=$0;getline;if(match($0,"ENTRGCSERV")){print s;print}}' file.txt
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1

-----Post Update-----

match function help is not in Sun os
# 14  
Old 06-12-2009
Quote:
Originally Posted by helplineinc
Hi I tried code on SunOS and getting mentioed error
awk '/^CRMSUB/{s=$0;getline;if(match($0,"ENTRGCSERV")){print s;print}}' file.txt
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1

-----Post Update-----

match function help is not in Sun os
I dont see any error(not using Sun OS though).. And, I get output, when I change ^CRMSUB to CRMSUB.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

2. Red Hat

Rm -rf * sequence

If I run rm -rf * command under one parent directory. /data > rm -rf * Is there anyway to know which files will be deleted first ? Start using code tags please, ty. (2 Replies)
Discussion started by: sameermohite
2 Replies

3. Shell Programming and Scripting

Need sequence no in the grep output

Hi, How to achieve the displaying of sequence no while doing grep for an output. Ex., need the output like below with the serial no, but not the available line number in the file S.No Array Lun 1 AABC 7080 2 AABC 7081 3 AADD 8070 4 AADD 8071 5 ... (3 Replies)
Discussion started by: ksgnathan
3 Replies

4. Shell Programming and Scripting

Grep regex to ignore sequence only if surrounded by fwd-slashes

Hi, I've got a regex match to perform in a Bash script and can't quite get it right. Basically I want to match all IP address like sequences in a file which may or may not contain an IP address but with the extra qualification of ignoring any IP-like sequence which begins and ends with a... (27 Replies)
Discussion started by: gencon
27 Replies

5. Red Hat

Grep doesn't understand escape sequence?

I ran the following grep and sed command. grep "\t" emp.txt sed -n '/\t/p' emp.txt grep treated the '\' as to escape t and took the pattern as literal t whereas sed took the pattern as tab. That means , grep doesn't understand escape sequence!!!!!! what to do to make grep... (8 Replies)
Discussion started by: ravisingh
8 Replies

6. Shell Programming and Scripting

find common entries and match the number with long sequence and cut that sequence in output

Hi all, I have a file like this ID 3BP5L_HUMAN Reviewed; 393 AA. AC Q7L8J4; Q96FI5; Q9BQH8; Q9C0E3; DT 05-FEB-2008, integrated into UniProtKB/Swiss-Prot. DT 05-JUL-2004, sequence version 1. DT 05-SEP-2012, entry version 71. FT COILED 59 140 ... (1 Reply)
Discussion started by: manigrover
1 Replies

7. Shell Programming and Scripting

Check Sequence

* Expiry DATE: * Address1: Address2: Address3: Address4: Address5: * PO_ref_number: aadad HolderId_1: HolderId_2: HolderId_3: HolderId_4: * adad: 00000 ada: 00000 adad: RANDOM adad: RANDOM ****************************** (4 Replies)
Discussion started by: arunshankar.c
4 Replies

8. Shell Programming and Scripting

ID generation in sequence

i have an xml tag. The value for the tag should be iterated through out the xml document. eg: <data><id><id><name>a</name><addr>aaa</addr><phnumb>3456</phnumb><state>ca</state><city>ny</city></data>... (6 Replies)
Discussion started by: Sgiri1
6 Replies

9. Shell Programming and Scripting

escape sequence for $

Hi all, I have a requirement where the variable name starts with $, like $Amd=/home/student/test/ How to work wit it? can some one help me, am in gr8 confusion:confused: (5 Replies)
Discussion started by: shreekrishnagd
5 Replies

10. Solaris

STOP A sequence

Hi, I have a sun sparc system. I don't have a sun keyboard, hence i connected a pc keyboard. I would like to know the "STOP A" equivalent command to be used on pc keyboard. Regards, Raja (4 Replies)
Discussion started by: RajaRC
4 Replies
Login or Register to Ask a Question