search patterns


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting search patterns
# 1  
Old 02-24-2006
search patterns

hello,

i have an input file of about 50,00,000 lines. few of its lines are as follows:

<CR:0023498789,TPO-14987084;BO=IC&SUB=ALLP
<CF:0023498789,CB=YES;BIL&NC=NO
<CF:0023498789,CW=NO;NS=NO
<GC:0023498789,CG=YES;TPO&NC=YES

<CR:0024659841,TPO-14484621;BO=NO&BA=OC&SUB=ALLH
<CF:0024659841,CB=YES;NC=NO
<CF:0024659841,CW=YES;NC=NO&NS=YES
<GS:0024659841,CU=1234;
<GL:0024659841,PCU=3462;NS=NO

<CR:0026454521,TPO-14525893;BO=IC&SUB=ALLJ
<GL:0026454521,PCU=75321;NC=NO&NS=NO

there no blank lines in input file.
0023498789 , 0024659841 , 0026454521. these are some needed numbers.
there are about 8,00,000 unique numbers in file. Off which usefull are just 2,50,000. i do not require numbers, whose lines contain 'BIL'. Like the second line.
<CF:0023498789,CB=YES;BIL&NC=NO
since BIL occurs so i do not require any line containing 0023498789.

in my output i require
number#TPO#number_if_BO=IC#number_if_BA=OC#SUB#number_if_CU_exists #number_if_PCU_exists

the output for above lines should be:
0024659841#14484621##0024659841#ALLH#0024659841#0024659841
0026454521#14525893#14525893##ALLJ##0026454521
# 2  
Old 02-27-2006
just a pointer to go with,

Code:
grep -v `sed -n '/BIL/p' data | sed -e 's/^.*://;s/,.*//'` data

regarding formatting i am not clear with.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search for patterns on different lines

im using the following code to search a log for entries on two different lines: awk 'BEGIN{count=0} /'"${firstpattern}"'/,/'"${secondpattern}"'/ { print; if ($0 ~ /'"${thirdpattern}"'/){count++}; } END { print count }' data.txt firstpattern="start error log" secondpattern="i am logging the... (1 Reply)
Discussion started by: SkySmart
1 Replies

2. Shell Programming and Scripting

Search Multiple patterns and display

Hi, I have scenario like below and need to search for multiple patterns Eg: Test Time Started= secs Time Ended = secc Green test Test Time Started= secs Time Ended = secc Green test Output: I need to display the text starting with Test and starting with Time... (2 Replies)
Discussion started by: weknowd
2 Replies

3. Shell Programming and Scripting

Search and count patterns

Hi, I have a text file the contents are like this now i want to search patterns Z , Z etc and count the occurrence of such patterns, after Z value can be any random digits, please help me it is urgent... output like this Z .............>5 Z ............>8 (9 Replies)
Discussion started by: sreejithalokkan
9 Replies

4. Shell Programming and Scripting

Search by patterns case

42 network read failed sv1 sv23 sv4 sv11 sv23 sv5 sv 7 48 client hostname could not be found sv21 sv78 sv19 sv22 sv111 sv203 sv5 sv 33 49 client did not start sv1 sv21 54 timed out connecting to client sv2 sv4 sv12 above is my file , I'd like to use a script to list all name... (5 Replies)
Discussion started by: Sara_84
5 Replies

5. Shell Programming and Scripting

How to search Multiple patterns in unix

Hi, I tried to search multiple pattern using awk trans=1234 reason=LN MISMATCH rec=`awk '/$trans/ && /'"$reason"'/' file` whenevr i tried to run on command promt it is executing but when i tried to implment same logic in shell script,it is failing i.e $rec is empty ... (6 Replies)
Discussion started by: ns64110
6 Replies

6. Shell Programming and Scripting

Search for the two patterns and print everything in between

Hi all, I have a file having data: @HWUSI-EAS1727:19:6:1:3674:984:0:1#GTTAATA NTTGGGTTTTCT @HWUSI-EAS1727:19:6:1:3674:984:0:1#GTTA... NTTGGGTTTTCT @HWUSI-EAS1727:19:6:1:3674:984:0:1#.....CT NTTGGGTTTTCT I want to print everything starting from # till line ends. can you please help me how... (5 Replies)
Discussion started by: pirates.genome
5 Replies

7. UNIX for Dummies Questions & Answers

Printing the lines using search patterns

Hi all , i need an help here.!!!! i have a file that contains /etc/passwd files from some servers. i need a script which search for presence of a user in the servers. like if i give 51144 to the script. the should be o/p Please help on this..... (4 Replies)
Discussion started by: sudharson
4 Replies

8. Shell Programming and Scripting

search multiple patterns

I have two lists in a file that look like a b b a e f c d f e d c I would like a final list a b c d e f I've tried multiple grep and awk but can't get it to work (8 Replies)
Discussion started by: godzilla07
8 Replies

9. Shell Programming and Scripting

sed search alternately for patterns

hi all, I am trying to do search on a gzip file. The file has <pattern1> Data.. <pattern2> data <pattern1> data <patter2> I want to print each pattern 1 and the corrresponding pattern2. If pattern 2 fails to appear and pattern 1 appears, I do not want to print pattern1 and... (3 Replies)
Discussion started by: baskar123
3 Replies

10. UNIX Desktop Questions & Answers

how to search files efficiently using patterns

hi friens, :) if i need to find files with extension .c++,.C++,.cpp,.Cpp,.CPp,.cPP,.CpP,.cpP,.c,.C wat is the pattern for finding them :confused: (2 Replies)
Discussion started by: arunsubbhian
2 Replies
Login or Register to Ask a Question