Simple question from simple user

Simple question from simple user

Post by Jeremy Cro » Fri, 14 May 1993 18:14:47



Hi - can anyone help me with this problem?  What I want to do, is to
run the following egrep commands repeatedly, whilst incrementing a
variable in the command line:

egrep ^1[\ ] name.1 | wc -l
egrep -v ^1[\ ] name.1 > name.2

So, I'd then want this to happen all over again, but with all the
numbers in the above incremented:

egrep ^2[\ ] name.2 | wc -l
egrep -v ^2[\ ] name.2 > name.3

There must be a way of getting a loop to do this automatically.  Could
someone mail me with ideas?
Thanks for your help,
Jeremy

--
Jeremy D.M. Crowe, Edinburgh University | Phone: +44 (0)31 650 2713
Department of Artificial Intelligence   | Fax: +44 (0)31 650 6516


 
 
 

Simple question from simple user

Post by glenn.robitail » Wed, 19 May 1993 23:13:28



Quote:>Hi - can anyone help me with this problem?  What I want to do, is to
>run the following egrep commands repeatedly, whilst incrementing a
>variable in the command line:

>egrep ^1[\ ] name.1 | wc -l
>egrep -v ^1[\ ] name.1 > name.2

>So, I'd then want this to happen all over again, but with all the
>numbers in the above incremented:

>egrep ^2[\ ] name.2 | wc -l
>egrep -v ^2[\ ] name.2 > name.3

>There must be a way of getting a loop to do this automatically.  Could
>someone mail me with ideas?

# bourne shell Example!, tailor to your local shell

i=1
max=9
while [ $i -lt $max ]
do
        j=`expr $i + 1`         # j = i + 1

        egrep ^${i}[\ ] name.${i} | wc -l
        egrep -v ^${i}[\ ] name.${i} > name.${j}

        i=$j
done
--
Glenn Robitaille

(908) 457-5072

 
 
 

1. A simple question deserving a simple answer

: What does Unix (Specifically Linux) look like?  

A bunch of ones and zeros ;-)

: Is it like Dos? Windows?

No, thank God.

: Something else?

Yes.

There's a simple answer...

--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming

2. technical information on Solaris7

3. a simple sed question ( there all simple :> )

4. print filters for PostScript printers

5. Simple FTP question (very simple)

6. Developer Panel Invitation

7. simple question about simple code

8. Trouble w/Multia (UDB) RH 5.1 installation

9. Simple question for us simple minded.

10. Simple question - simple answer?

11. simple user/group question for linux

12. simple date problem, simple solution?

13. New User...simple? dir & password questions..