PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Excluding an output line
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Excluding an output line

Réponse
 
LinkBack Outils de la discussion
Vieux 03/12/2006, 06h58   #1
Owen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Excluding an output line


How can I run this command,

repquota -v /home | awk '{if ($3 > $4) print $0 }'

but prevent it outputting lines starting with a #ddddd ie

#11779 -- 8 0 0 2 0 0

It would sure make life easier

TIA


Owen

  Réponse avec citation
Vieux 03/12/2006, 07h28   #2
RolandRB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Excluding an output line


Owen wrote:
> How can I run this command,
>
> repquota -v /home | awk '{if ($3 > $4) print $0 }'


Try: if ($3 > $4 || substr($0,1,1) != "#")

> but prevent it outputting lines starting with a #ddddd ie
>
> #11779 -- 8 0 0 2 0 0
>
> It would sure make life easier
>
> TIA
>
>
> Owen


  Réponse avec citation
Vieux 03/12/2006, 07h42   #3
Owen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Excluding an output line


RolandRB wrote:
> Owen wrote:
> > How can I run this command,
> >
> > repquota -v /home | awk '{if ($3 > $4) print $0 }'

>
> Try: if ($3 > $4 || substr($0,1,1) != "#")



Nearly, but thanks for the clue, this worked

repquota -v /home | awk '{if (($3 > $4) && (substr($0,1,1) != "#"))
print $0 }'


Thanks

Owen



>
> > but prevent it outputting lines starting with a #ddddd ie
> >
> > #11779 -- 8 0 0 2 0 0
> >
> > It would sure make life easier
> >
> > TIA
> >
> >
> > Owen


  Réponse avec citation
Vieux 03/12/2006, 07h54   #4
RolandRB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Excluding an output line


Owen wrote:
> RolandRB wrote:
> > Owen wrote:
> > > How can I run this command,
> > >
> > > repquota -v /home | awk '{if ($3 > $4) print $0 }'

> >
> > Try: if ($3 > $4 || substr($0,1,1) != "#")

>
>
> Nearly, but thanks for the clue, this worked
>
> repquota -v /home | awk '{if (($3 > $4) && (substr($0,1,1) != "#"))
> print $0 }'
>
>
> Thanks
>
> Owen


Yes "&&" and not "||" - duh! It was before my morning cup of coffee.

>
> >
> > > but prevent it outputting lines starting with a #ddddd ie
> > >
> > > #11779 -- 8 0 0 2 0 0
> > >
> > > It would sure make life easier
> > >
> > > TIA
> > >
> > >
> > > Owen


  Réponse avec citation
Vieux 03/12/2006, 08h08   #5
RolandRB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Excluding an output line


Owen wrote:
> RolandRB wrote:
> > Owen wrote:
> > > How can I run this command,
> > >
> > > repquota -v /home | awk '{if ($3 > $4) print $0 }'

> >
> > Try: if ($3 > $4 || substr($0,1,1) != "#")

>
>
> Nearly, but thanks for the clue, this worked
>
> repquota -v /home | awk '{if (($3 > $4) && (substr($0,1,1) != "#"))
> print $0 }'
>
>
> Thanks
>
> Owen


You could have piped it grep to get rid of those lines like this:

repquota -v /home | awk '{if ($3 > $4) print $0 }' | grep -v ^#

....but then you already knew that, didn't you?

  Réponse avec citation
Vieux 03/12/2006, 10h19   #6
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Excluding an output line

2006-12-2, 22:58(-08), Owen:
>
> How can I run this command,
>
> repquota -v /home | awk '{if ($3 > $4) print $0 }'
>
> but prevent it outputting lines starting with a #ddddd ie
>
> #11779 -- 8 0 0 2 0 0
>
> It would sure make life easier

[...]

repquota -v /home |
POSIXLY_CORRECT=1 awk '$3 > $4 && ! /^#[0-9]{5}/'

--
Stéphane
  Réponse avec citation
Vieux 03/12/2006, 10h20   #7
Owen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Excluding an output line


RolandRB wrote:
> Owen wrote:
> > RolandRB wrote:
> > > Owen wrote:
> > > > How can I run this command,
> > > >
> > > > repquota -v /home | awk '{if ($3 > $4) print $0 }'
> > >
> > > Try: if ($3 > $4 || substr($0,1,1) != "#")

> >
> >
> > Nearly, but thanks for the clue, this worked
> >
> > repquota -v /home | awk '{if (($3 > $4) && (substr($0,1,1) != "#"))
> > print $0 }'
> >
> >
> > Thanks
> >
> > Owen

>
> You could have piped it grep to get rid of those lines like this:
>
> repquota -v /home | awk '{if ($3 > $4) print $0 }' | grep -v ^#
>
> ...but then you already knew that, didn't you?



I tried piping it thru a grep --exclude=/something/ . I just looked up
man grep and have no idea why I did that. Time to go to bed!

Thanks again

Owen

  Réponse avec citation
Vieux 03/12/2006, 10h52   #8
Radoulov, Dimitre
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Excluding an output line


"Owen" <xemoth@gmail.com> wrote in message
news:1165129096.825454.209430@79g2000cws.googlegro ups.com...
>
> How can I run this command,
>
> repquota -v /home | awk '{if ($3 > $4) print $0 }'
>
> but prevent it outputting lines starting with a #ddddd ie
>
> #11779 -- 8 0 0 2 0 0



gawk --re-interval '$3>$4&&$1!~/#[0-9]{5}/'


Regards
Dimitre


  Réponse avec citation
Vieux 03/12/2006, 11h21   #9
RolandRB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Excluding an output line


Owen wrote:
> RolandRB wrote:
> > Owen wrote:
> > > RolandRB wrote:
> > > > Owen wrote:
> > > > > How can I run this command,
> > > > >
> > > > > repquota -v /home | awk '{if ($3 > $4) print $0 }'
> > > >
> > > > Try: if ($3 > $4 || substr($0,1,1) != "#")
> > >
> > >
> > > Nearly, but thanks for the clue, this worked
> > >
> > > repquota -v /home | awk '{if (($3 > $4) && (substr($0,1,1) != "#"))
> > > print $0 }'
> > >
> > >
> > > Thanks
> > >
> > > Owen

> >
> > You could have piped it grep to get rid of those lines like this:
> >
> > repquota -v /home | awk '{if ($3 > $4) print $0 }' | grep -v ^#
> >
> > ...but then you already knew that, didn't you?

>
>
> I tried piping it thru a grep --exclude=/something/ . I just looked up
> man grep and have no idea why I did that. Time to go to bed!
>
> Thanks again


You could also use awk's regular expression filter (or whatever it is
called) with:

awk '/^[^#]/ && $3 > $4'

The above should work, I think.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 14h04.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15343 seconds with 17 queries