Need Help on awk!!!! **** Urgent **** 
Author Message
 Need Help on awk!!!! **** Urgent ****

Hi everyone, I having difficulty writing a short script if
someone know how to do it, please let me know, thanks a lot.

The problem is to input a title of a paragraph and display the
whole paragraph

eg.
        if the script is call "jargfind" and we call it by
        the pagraph title

        % jargfind loss

        it will automaticly find the section
        if the input file is like

        :loss: n.   Something (not a person) that loses;
        :lossage:  /los'*j/ n. The result of a bug or malfunction...
                    ....
        :lot:  n.  ........

        the output will be
        :loss: n.   Something (not a person) that loses;

                Any help will be appreciated.



Fri, 09 Apr 1999 03:00:00 GMT  
 Need Help on awk!!!! **** Urgent ****



Quote:
>The problem is to input a title of a paragraph and display the
>whole paragraph
>        % jargfind loss
>        it will automaticly find the section
>        if the input file is like
>        :loss: n.   Something (not a person) that loses;
>        :lossage:  /los'*j/ n. The result of a bug or malfunction...
>                    ....
>        :lot:  n.  ........
>        the output will be
>        :loss: n.   Something (not a person) that loses;

If the para-header is a title separated by colons :, then try this

Put the following in a file (ps.awk)
{if (substr($0,1,1) ==":") {
  flag=0
  if ($1 == ":" ss ":") flag=1}
 if (flag == 1) print}

and call it with awk -f ps.awk ss="loss" text-file
You put the keyword (in correct upper/lower case!) as the value of ss

Hope this helps
Mark
--
Mark Katz
ISPC, London - Innovation in data-delivery tools
Tel: (44) 181-455 4665, Fax (44) 181-458 9554
** Visit our website on http://www.efiche.com/efiche **



Fri, 09 Apr 1999 03:00:00 GMT  
 Need Help on awk!!!! **** Urgent ****

Quote:

>        if the script is call "jargfind" and we call it by
>        the pagraph title
>        % jargfind loss
>        it will automaticly find the section
>        if the input file is like
>        :loss: n.   Something (not a person) that loses;
>        :lossage:  /los'*j/ n. The result of a bug or malfunction...
>                    ....
>        :lot:  n.  ........
>        the output will be
>        :loss: n.   Something (not a person) that loses;

What about:

#!/bin/ksh
#
# Filename: jargfind
#
# Usage: jargfind ITEM
#
# Description: look for a line beginning with ':ITEM:' and displays lines
# starting from this one until it encounters a line beginning with ':'
#
if [[ -z "$1" ]]
then
        print "Usage: $0 ITEM"
        exit 1
else
        ITEM=$1
fi
awk '
BEGIN {Ok=0;}
/^:/ {if ( Ok == 1 ) {Ok=0;}}
/^:'"$ITEM"':/ {Ok=1;}
{if ( Ok == 1 ) {print $0;}}
' FileToLookAt

Hope this helps,
Patrice.

---------------------------------------------------------------------

|  #include <disclaimer.h>  |   V-mail : (+33) 92 29 39 49 + 3902   |
|-------------------------------------------------------------------|



Sat, 10 Apr 1999 03:00:00 GMT  
 Need Help on awk!!!! **** Urgent ****

Quote:

> ...
> if the script is call "jargfind" and we call it by
> the pagraph title

> % jargfind loss

> it will automaticly find the section
> if the input file is like

> :loss: n.   Something (not a person) that loses;
> :lossage:  /los'*j/ n. The result of a bug or malfunction...
>                     ....
> :lot:  n.  ........

> the output will be
> :loss: n.   Something (not a person) that loses;

> Any help will be appreciated.


There are many ways leading to Rome, one might be this
awk-script (store in file jarg.awk)

$1 ~ "^:" WORD ":$" {print}

invoke with

awk -f jarg.awk -v WORD="xxxx" inputfile

This script does not work if your search string xxxx
contains any regular expression metacharacters
like $[]^?.+* but should work OK for *normal* words!

Truls Thirud



Fri, 16 Apr 1999 03:00:00 GMT  
 Need Help on awk!!!! **** Urgent ****

Quote:

> Hi everyone, I having difficulty writing a short script if
> someone know how to do it, please let me know, thanks a lot.

> The problem is to input a title of a paragraph and display the
> whole paragraph

> eg.
>    if the script is call "jargfind" and we call it by
>    the pagraph title

>    % jargfind loss

>    it will automaticly find the section
>    if the input file is like

>    :loss: n.   Something (not a person) that loses;
>    :lossage:  /los'*j/ n. The result of a bug or malfunction...
>                     ....
>    :lot:  n.  ........

>    the output will be
>    :loss: n.   Something (not a person) that loses;

>    Any help will be appreciated.


This is my second attempt at your urgent (...) problem.
The first time I missed the point of the jargonfile
having sections with more than one line. If the
sections are separated by one blank line this
one-liner (jarg.awk) should do it:

$1 ~ "^:" WORD ":$", NF==0

Invoke this script with

awk -f jarg.awk -v WORD=wwww jargonfile

wwww is the word you are searching for. If you are
running on a unix box you could build a simple shell
script for the whole thing, just as you could wrap
it in a bat-file on a dos/windows-box.

Thanks to Mark Katz for straightening out my
first reply.

Enjoy!

Truls Thirud



Mon, 19 Apr 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. URGENT: Need help with AND binary operation in awk

2. URGENT-help needed-URGENT

3. urgent! need help with database bindings

4. 2nd post Urgent: Need help with FM2.9!

5. urgent help needed

6. clarion 5.5 urgent help needed

7. Help needed... URGENT

8. *URGENT* Help need with data export

9. Urgent-Need help with batch update

10. Urgent help needed about Clarion 4

11. Need urgent help!!!

12. Urgent Help Needed !!! RE:Copying of procedures

 

 
Powered by phpBB® Forum Software