Matching a pattern 250 characters up and down stream


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Matching a pattern 250 characters up and down stream
# 1  
Old 06-27-2012
Matching a pattern 250 characters up and down stream

hii all

i have a file a which contains some thing like this
strand smthg position
+ yyx 3020
- yyw 10,000

now i have another file (file2) which contains the data starting from 1 to n positions

i want to refer first file if + appears it should go to eg 3020 position in file 2 and see for a pattern match say $abc at 250 characters after 3020 (i,e., 3270).

if " -" appears it shud go 250 characters before 3020 and search for the pattern $abc.
how can i do it
# 2  
Old 06-27-2012
Quote:
Originally Posted by anurupa777
hii all

i have a file a which contains some thing like this
strand smthg position
+ yyx 3020
- yyw 10,000

now i have another file (file2) which contains the data starting from 1 to n positions

i want to refer first file if + appears it should go to eg 3020 position in file 2 and see for a pattern match say $abc at 250 characters after 3020 (i,e., 3270).

if " -" appears it shud go 250 characters before 3020 and search for the pattern $abc.
how can i do it
Please post a bit bigger datasets of your both input files and your expected output files.

Please use code tags when u submit ur data.
# 3  
Old 06-27-2012
ya i am sorry. here is the data for file 1 having 3 columns

+ yyx 10
_ yyw 10,000
_ yyx 1,000
_ yyw 10,503
+ yyx 30298

2nd file has aababbabahhhnjkmlipolmkijnhbu.........................

first it should read the file1 3rd column (10) and check for first column (+) . if it is + it should move 250 characters a head of present position (10) in file 2 and check for a pattern say $abc. am i clear nw?
# 4  
Old 06-27-2012
I'm thinking this would work quite well if the whole of file 2 could be loaded into memory, How many positions are in file2?
# 5  
Old 06-28-2012
it would have a maximum of 3-4 billion. i can load it in server no prob with memory i guess
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

2. Shell Programming and Scripting

Deleting lines from a stream after matching a pattern

Hi, I have a requirement to to an ldapsearch and remove the shadow attributes in the output file. What I do is ldapsearch() | operation to remove shadow > FILE The ldapsearch gives output like this(with same line formation): objectClass: FSConfig objectClass: extensibleObject fsCAIP:... (10 Replies)
Discussion started by: lorzinian
10 Replies

3. Shell Programming and Scripting

Removing all lines prior to the last pattern in a file/stream

Hi all, I didn't find anything that specifically answers this after searching for a bit, so please forgive me if this has been covered before. I'm looking to delete all lines prior to the last occurrence of a string in a file or stream from within a shell script (bash.) A bit of... (4 Replies)
Discussion started by: LivinFree
4 Replies

4. Shell Programming and Scripting

Matching a pattern between two characters (sed)

Hi there, I have a file with lines like these: 0105:ffff0000:001b:01f4:25:434 0299:ffff0000:0009:01f4:2:319 02d2:ffff0000:000e:01f4:2:507 The above values are split up using ":" characters. I would like capture each value, no matter what length. Take for example the first line... (8 Replies)
Discussion started by: MastaG
8 Replies

5. Shell Programming and Scripting

pattern match in live stream

hi! i have a situation like this where i have to analyse the live log generated from /bin/scp -v you@example.com is if a pattern like say "Too many connections" comes i shud be able to identify it . (3 Replies)
Discussion started by: phpsnook
3 Replies

6. UNIX for Dummies Questions & Answers

pattern matching w/ unexpected characters

how do i check if the first character is a parenthese in pattern matching? if ] obviously doesnt work. How do I use it to compare so it doesnt try to use it to group. (5 Replies)
Discussion started by: questionasker
5 Replies

7. Shell Programming and Scripting

counting the lines matching a pattern, in between two pattern, and generate a tab

Hi all, I'm looking for some help. I have a file (very long) that is organized like below: >Cluster 0 0 283nt, >01_FRYJ6ZM12HMXZS... at +/99% 1 279nt, >01_FRYJ6ZM12HN12A... at +/99% 2 281nt, >01_FRYJ6ZM12HM4TS... at +/99% 3 283nt, >01_FRYJ6ZM12HM946... at +/99% 4 279nt,... (4 Replies)
Discussion started by: d.chauliac
4 Replies

8. Shell Programming and Scripting

Truncate the content within alt attribute to first 250 characters.

I have a xml file which contains image tag as follows: <image><img src="wstc_0007_0007_0_img0001.jpg" width="351" height="450" alt="This is the cover page. Brazil &#x2022; Japan &#x2022; Korea &#x2022; Mexico &#x2022; Singapore &#x2022; Spain" type="photograph" orient="portrait"/></image> ... (5 Replies)
Discussion started by: parshant_bvcoe
5 Replies

9. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies
Login or Register to Ask a Question