awk problem 
Author Message
 awk problem

disclaimer: I'm no expert

#!/bin/(whatever shell)
for id in `awk -F: ' $3==0 && $1 !="root" { print $1 }' /etc/passwd` ;
do
    your routine
done

Joe

Quote:


> > I am trying to run the following script but keep getting a syntax
> > error at line 1, specifically "awk: syntax error near line 1":

> > #!/bin/sh

> > #
> > # The following code will alert root if any user
> > # other than root has uid 0
> > #
> > for id in `awk 'FS=":" {if ( $3 == 0 && $1 != "root" ) \
> > print $1}' /etc/passwd`
> > do

> > **************************************************************
> > *
> > *       ALERT!  Login ID `echo ${id}` has uid 0
> > *       `date "+Detected on DATE : %D Time :%r"`
> > *
> > **************************************************************

> > EOF
> > done

> for id in `awk -F: '$3==0 && $1 != "root" {print $1}'`
> do
> ...
> done

> Heiner
> --
>  ___ _

> \__ \  _/ -_) V / -_) ' \    UNIX Shell Script Programmers: visit
> |___/\__\___|\_/\___|_||_|   http://www.*-*-*.com/

--

access to a news server; thanks!
Disclaimer: opinions expressed my own and not representative of my employers


Sat, 22 Dec 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. An awk problem , need help!

2. awk problems on Solaris

3. awk problem

4. Awk Problem: Changing Input Data Format

5. awk problem sorting and deduping file

6. simple awk problem

7. help with a tricky awk problem...

8. multiple regression using AWK Problem

9. AWK: Problem processing first line

10. solved awk-problems

11. Small awk problem

12. Sharing a subtle awk problem

 

 
Powered by phpBB® Forum Software