Harder filtering, HELP ME PLEASE


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Harder filtering, HELP ME PLEASE
# 1  
Old 11-10-2009
Data Harder filtering, HELP ME PLEASE

Hi,

I wrote a post last friday but i think that i have not explained well.

I need help with shell script commands to filter information from a text file. This text file is divided into subsections of several lines that begin with a date as a header. There are no blank lines.

The aim is to create a script that receives as input parameter a date and ID number, and it shows only the parragraphs who start whit this date and contains in one of their lines the ID number. żDoes anyone know how I can filter out entire paragraphs containing a certain string? I thought of using SED or AWK. THANKS
# 2  
Old 11-10-2009
Yes, Pls post the input the desired output data.
# 3  
Old 11-10-2009
Original file:

2009-11-10 09:32:13:
TextTextTextTextTextTextTextTextTextTextText
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText
TextTextTextTextText^tracking^=^id^="Pqe86V0prHWvSk5zfUD4KqEHaE"Te
2009-11-10 09:32:13TextTextTextTextTextTextTextTextTextTextTextText
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText
Text^tracking^={^id^="n-Krg4-/r/VE5zfVD4EHaE"TextTextTextTextText
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText
2009-11-10 09:32:13Text^tracking^{^id^="TA1vf/kCrHWyzfTD4KqEHaE"
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText

Output (finding ID: "n-Krg4-/r/VE5zfVD4EHaE"):

2009-11-10 09:32:13TextTextTextTextTextTextTextTextTextTextTextText
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText
Text^tracking^={^id^="n-Krg4-/r/VE5zfVD4EHaE"TextTextTextTextText
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText

If there are more paragraphs with this ID would show all
# 4  
Old 11-10-2009
Code:
awk  'BEGIN {RS="2009-11-10"}  /n-Krg4-\/r\/VE5zfVD4EHaE/ {print "2009-11-10"$0}' urfile

# 5  
Old 11-10-2009
Thank you very much rdcwayx, but i have a problem, the date can appear behind the text in the parragraph and the output is not right. One solution would be put in the RS "^ 2009-11-10" to capture those dates that appear in the top of the line but I think AWK doesn't let to put regular expressions in the RS field and server does not have GAWK. I got insert with SED a blank line between parragraphs: cat file | sed '/^2009-11-10/{x;p;x;}' , and the new file looks like this:

2009-11-10 09:32:13:TextTextTextTextTextTextTextTextTextTextText
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText
TextTextTextTextText^tracking^=^id^="Pqe86V0prHWvSk5zfUD4KqEHaE"Te

2009-11-10 09:32:13
TextTextTextTextTextTextTextTextTextTextTextText
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText
Text^tracking^={^id^="n-Krg4-/r/VE5zfVD4EHaE"TextTextTextTextText
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText

2009-11-10 09:32:13
Text^tracking^{^id^="TA1vf/kCrHWyzfTD4KqEHaE"
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText

Can you think of something? Thank you
# 6  
Old 11-10-2009
The rules for these forums are quite clear. Do not post questions with childish "Please Help Me" in the subject.

Everyone who comes here is seeking help.

Follow forum rules or do not post here.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help on filtering

Hi experts, I have a file image.csv as below: COMPUTERNAME,23/07/2013,22/07/2013,21/07/2013,20/07/2013,19/07/2013,18/07/2013,17/07/2013 AED03852180,3,3,3,3,3,3,3 AED03852181,3,3,3,3,3,3,1 AED09020382,3,0,3,0,3,3,3 AED09020383,1,3,3,3,2,1,3 AED09020386,3,3,0,3,3,0,3 ... (4 Replies)
Discussion started by: zaq1xsw2
4 Replies

2. UNIX for Dummies Questions & Answers

filtering out certain output

hi guys, i have a long output and cant figure out a flexible way to show the meta members from a device. please help. some device have 2,4 or 8 meta members but for this example i have 4 meta members, what is a flexible way to pull them out from this output? need your inputs thanks. ... (4 Replies)
Discussion started by: prodigy06
4 Replies

3. UNIX for Dummies Questions & Answers

Filtering the duplicates

Hello, I want to filter all the duplicates of a record to one place. Sample input and output will give you better idea. I am new to unix. Can some one help me on this? Input: 7488 7389 chr1.fa chr1.fa 3546 9887 chr5.fa chr9.fa 7387 7898 chrX.fa chr3.fa 7488 7389 chr1.fa chr1.fa... (2 Replies)
Discussion started by: koneru_18
2 Replies

4. Shell Programming and Scripting

Filtering

Hi I am interested in DNS resolving a set of sites and each time the output is different- $ host www.yahoo.com www.yahoo.com is an alias for fd-fp3.wg1.b.yahoo.com. fd-fp3.wg1.b.yahoo.com is an alias for ds-fp3.wg1.b.yahoo.com. ds-fp3.wg1.b.yahoo.com is an alias for... (1 Reply)
Discussion started by: jamie_123
1 Replies

5. AIX

Need help with filtering

Hi!! I have a bit of a task here and filtering/scripting not my strongest. I have to collect info of approx 1100 hdiskpower.so i have appended all the hdisk into a text file and i need it to run the command lscfg -vl to confirm if the drive is symmetrix. here's what i have so far at... (3 Replies)
Discussion started by: vpundit
3 Replies

6. Shell Programming and Scripting

Please help me to do some filtering

I have to grep a pattern. scenario is like :- Suppose "/etc/sec/one" is a string, i need to check if this string contains "one" using any utility something like if /etc/sec/one | grep ; then Thanks in advance Renjesh Raju (3 Replies)
Discussion started by: Renjesh
3 Replies

7. Shell Programming and Scripting

filtering column #7

Hi, I want to filter a file that contains 11 columns. Basically I want to filter based on column 7. The file that I have looks like this: 1 3 4 AB 45 run PPPPPPPOOOOOOOLLLLLLLL... 5 9 ui So for column 7 i want to delete lines that have a . OR more than 2 . So if I were to... (3 Replies)
Discussion started by: phil_heath
3 Replies

8. UNIX for Dummies Questions & Answers

Filtering a file

I have a list of directories looking something like; /usr/local/1/in /usr/local/1/out /usr/local/1/archive /usr/local/2/in /usr/local/2/out /usr/local/2/archive /usr/local/3/in /usr/local/3/out /usr/local/3/archive Is there a way I can filter the out and archive directories so I... (5 Replies)
Discussion started by: JayC89
5 Replies

9. HP-UX

port filtering

hi All I have to do port filtering on Unix servers.But unfortunately ip filter is not installed on the server.Now i am thinking of stopping the services.Can anybody tell me how do i go about it?Somebody told me about etc/services option?But that does not look a viable option.I think that is only... (0 Replies)
Discussion started by: ujjwalmohan
0 Replies
Login or Register to Ask a Question