Difficult Filtering Problem


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Difficult Filtering Problem
# 1  
Old 06-28-2003
Question Difficult Filtering Problem

Sir,
I have a file containing say 1000 lines that contain 100 paragraphs of 10 lines each separated by blank lines.I have to match a pattern or a string "hdfhasdjkasdhs" and print the complete paragraphs containing these strings.I can do this with the help of line editor ex,but how can I use Shell(sh) to perform this operation.I DO NOT have a C shell or CSH.Please tell me what combination I should use in sed/awk or is there any other way to do it.
# 2  
Old 06-30-2003
Try this:
Code:
#! /usr/bin/ksh
target=hdfhasdjkasdhs

sed -n -e "
:loop
s/^$//
t test
H
n
b loop
:test
g
s/${target/${target}/
t want
s/^.*//
h
d
:want
p
:final
s/^.*//
h"
exit 0

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

A little difficult: investigate Xenix and slattach problem

I know Xenix is a little outdated, and is dangerous to use on network. But this is a virtual machine, and I like to play retrocomputing sometime. The question is..why ftp over slip doesn't work? I've set this Xenix vm on libvirt <domain type='kvm' id='5'... (2 Replies)
Discussion started by: Linusolaradm1
2 Replies

2. Programming

Difficult in analyzing an algorithm

Hello, I was reading Heuritics text and came across an algorithm below. Finding hard to analyze it can any one help me out below... How to analyze if I take say no. of types are 5 and each type has say 20 coins. thanks. Let {c1, c2...cn=1} be a set of distinct coin types where ci is... (1 Reply)
Discussion started by: sureshcisco
1 Replies

3. Shell Programming and Scripting

Difficult problem: Complex text file manipulation in bash script.

I don't know if this is a big issue or not, but I'm having difficulties. I apoligize for the upcoming essay :o. I'm writing a script, similar to a paint program that edits images, but in the form of ANSI block characters. The program so far is working. I managed to save the image into a file,... (14 Replies)
Discussion started by: tinman47
14 Replies

4. UNIX for Dummies Questions & Answers

difficult problem with function declaration

Hello, I have a problem with the declaration of a function. This is how I declare the function : c:63: void foo(threadpool *tp,void (*func)(void*), (void*)arg); Inside main, I call it like this: main(){ .......... threadpool y; c:104: ... (4 Replies)
Discussion started by: garag11
4 Replies

5. Shell Programming and Scripting

grep filtering problem

I'm working on writing a shell script that logs out whenever I have a firefox process running during certain times of the day (1 am - 8 am). I'll put it in crontab when it runs properly unless someone knows of a different and better way to do this. Here it is so far. if ps ax | grep... (4 Replies)
Discussion started by: cokedude
4 Replies

6. UNIX for Dummies Questions & Answers

so difficult question about using grep

en...how to grep some words from some file, the goal is that, we donot want the words are exactly 9 charactor, and want to grep from some words that are longer than 9 and it contain a substring that with 9 different charactors (2 Replies)
Discussion started by: shrimpy
2 Replies

7. Shell Programming and Scripting

A difficult script (for me)

Hi, I'm a beginners, this is one of my first script, it's easy, but I don't know how to write this script: The script receive in input 4 parameters: 1) user_name 2) r and/or w and/or x ( rwx, rw, x, ....) 3) u and/or g and/or o ( u, uo, ugo, ...) 4) the path name The script print a... (2 Replies)
Discussion started by: DNAx86
2 Replies

8. UNIX for Dummies Questions & Answers

problem in filtering the file

-------------------------------------------------------------------------------- Hi, Plz help me out with this. I have some requirement like this..... I have a file like this... * CS sent email (11.20) CALYPSO 1031276 9076673 CDSHY FAILED Nov 19 2007 7:28AM OASYS: Unable to find CUSTOMER... (0 Replies)
Discussion started by: adityam
0 Replies

9. UNIX for Advanced & Expert Users

difficult sed command

Im trying to replace every line line1 line2 line3 with: line1 extraline1 line2 extraline2 line3 extraline3 with about 10 extra lines I am able to add axtra lines with: (17 Replies)
Discussion started by: Dave724001
17 Replies

10. Solaris

difficult time differences

:rolleyes: Hi, How to take the time diffence between start and finish time from a log file? It is like ..... started at Jun 20 23:20 . . ..... finished at Jun 21 01:40 Tryed so many ways but failed to ger exact way. :confused: Your help will be honoured. Ta........Lokesha (1 Reply)
Discussion started by: Lokesha
1 Replies
Login or Register to Ask a Question