Awk woes... - assn1a.gif (0/1) 
Author Message
 Awk woes... - assn1a.gif (0/1)


Quote:
> Hello all!

> I was wondering if someone could help me with this.
> This is only part of an assignment i'm workin on - only the displaying
part.

> I want to print a range of 20 lines (starting at a specific line) from the

file, but highlight the
Quote:
> ones that either match (or don't depending on the commandline options).
> I also want to do some cursor movement (supposed to be with tput) -

that's the problem i can't get
Quote:
> it to output starting at cup position 0 0 (ie. the top left corner).
> There will be some scrolling left/right/up/down etc so the lines won't

always be shown from column

Quote:
> 1.

> I've attached an image of what it should look like too.

> tia!

> Output format:

> 1:    kirk
> 2:    anita
> 3:    ken
> 4:    aaron
> 5:    kirk
> 6:    chris
> 7:    paul
> 8:    dana
> 9:    kathrin
> 10:   holly
> 11:   steve
> 12:   erik
> 13:   anita
> 14:   chris
> 15:   paul
> 16:   andrew
> 17:   malcolm

> \#!/bin/bash2

> # test variables

> pattern=kirk
> linenum=3
> colnum=2
> nflag=1
> maxcols=74

> stty -echo -icanon min 0 time 0 -icrnl
> clear
> tput cup 0 0

> awk ' "$pattern" NR=="'"$linenum"'",NR=="'"$linenum"'"+9

> BEGIN { line = 0 }

> {

>    system( "tput cup line 0" )
>    if ( "'"$nflag"'" == 1){
>       printf("%d:", NR)
>       system("tput cup line 6")
>    }

>    if ( $0 ~ var ){

>       system("tput smso")

>       if ( length($0) > "'"$maxcols"'"){
>          s = $0
>          s = substr(s, "'"$colnum"'", "'"$maxcols"'")
>          print s
>       }
>       else
>          print $0

>       system("tput rmso")

>    }
>    else {
>       if ( length($0) > "'"$maxcols"'"){
>          s = $0
>          s = substr(s, "'"$colnum"'", "'"$maxcols"'")
>          print s
>       }
>       else
>          print $0
>    }
>    line += 1

> }' var="$pattern" file

> stty echo icanon min 0 time 0 icrnl

If this is for a 3270 terminal, as I assume, then the top left-hand corner
is 1,1 not 0,0 surely - at least that's what my 3270 emulator says.

HTH
--
Peter S Tillier

Usual disclaimers, E&OE



Tue, 05 Aug 2003 01:31:18 GMT  
 Awk woes... - assn1a.gif (0/1)


Quote:
>If this is for a 3270 terminal, as I assume, then the top left-hand corner
>is 1,1 not 0,0 surely - at least that's what my 3270 emulator says.

Oh?  I'm curious as to why you assume it's a 3270.  Given that the OP
is using the tput command, which implies Unix-style termcap driven ttys
(ie, not necessarily 3270, or any other terminal type).

        - Dan C.

(ps- the reason I ask is to see if I'm missing anything from my days
as an IBM user.  :-)



Tue, 05 Aug 2003 14:29:51 GMT  
 Awk woes... - assn1a.gif (0/1)

Quote:


> >If this is for a 3270 terminal, as I assume, then the top left-hand
corner
> >is 1,1 not 0,0 surely - at least that's what my 3270 emulator says.

> Oh?  I'm curious as to why you assume it's a 3270.  Given that the OP
> is using the tput command, which implies Unix-style termcap driven ttys
> (ie, not necessarily 3270, or any other terminal type).

> - Dan C.

> (ps- the reason I ask is to see if I'm missing anything from my days
> as an IBM user.  :-)

Mainly because MVS/ISPF supports a tput macro for output and I spend all day
looking at 3270 mainframe (non-UNIX :-( ) output.  It's easy to get into a
groove isn't it?

--



Opinions expressed are my own and not necessarily those of my employer.



Tue, 05 Aug 2003 15:19:18 GMT  
 Awk woes... - assn1a.gif (0/1)


Quote:
>Mainly because MVS/ISPF supports a tput macro for output and I spend all day
>looking at 3270 mainframe (non-UNIX :-( ) output.  It's easy to get into a
>groove isn't it?

Yup, it sure is.  Hmm, I suppose Berkeley named the tput(1) command
after the macro from the IBM world.  Or maybe it's just a coincidence.

        - Dan C.



Thu, 07 Aug 2003 03:08:36 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Awk variable woes

2. common mistakes in awk: comparing awk with C

3. Awk compilers / Awk to C converters

4. Arrays in awk/awk help please!

5. Help with Awk, totally new to AWK programing

6. awk process in awk ??

7. AWK newbie is looking for a AWK help with his 1st program

8. run awk output thru tee inside awk

9. Awk within awk??

10. Awk in awk??

11. Outputting info from awk and using the info to name the awk output file

12. How Can i do AWK in AWK

 

 
Powered by phpBB® Forum Software