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 > gawk seach directory tree
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

gawk seach directory tree

Réponse
 
LinkBack Outils de la discussion
Vieux 05/12/2006, 19h26   #1
baltoinfo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut gawk seach directory tree

All,
I've seached until I've got a headache and no answers. I've found a
couple of close ones but not exactly what I'm looking for.

I'm looking for a simple cmd line or script to search a directory tree
with all of it's files and I am looking for one word in the files.
I've tried gawk, but can't seem to get it to traverse the sub
directories.
This is a just an example gawk '/hda1/ { print $0 }' /etc/mtab say I
don't know the word is in /etc/mtab
but I know the word is in etc. How do a search a directory.

thx in advance!

  Réponse avec citation
Vieux 05/12/2006, 19h32   #2
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: gawk seach directory tree

2006-12-5, 11:26(-08), baltoinfo:
> All,
> I've seached until I've got a headache and no answers. I've found a
> couple of close ones but not exactly what I'm looking for.
>
> I'm looking for a simple cmd line or script to search a directory tree
> with all of it's files and I am looking for one word in the files.
> I've tried gawk, but can't seem to get it to traverse the sub
> directories.
> This is a just an example gawk '/hda1/ { print $0 }' /etc/mtab say I
> don't know the word is in /etc/mtab
> but I know the word is in etc. How do a search a directory.

[...]

find /etc -type f -exec gawk /hda1/ {} +

With GNU grep:

grep -rhDskip hda1 /etc

--
Stéphane
  Réponse avec citation
Vieux 05/12/2006, 19h32   #3
Kenny McCormack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: gawk seach directory tree

In article <1165346796.331614.313050@79g2000cws.googlegroups. com>,
baltoinfo <funnsun34@hotmail.com> wrote:
>All,
>I've seached until I've got a headache and no answers. I've found a
>couple of close ones but not exactly what I'm looking for.
>
>I'm looking for a simple cmd line or script to search a directory tree
>with all of it's files and I am looking for one word in the files.
>I've tried gawk, but can't seem to get it to traverse the sub
>directories.
>This is a just an example gawk '/hda1/ { print $0 }' /etc/mtab say I
>don't know the word is in /etc/mtab
>but I know the word is in etc. How do a search a directory.
>
>thx in advance!
>


(cd to the top level of the tree you want to search)
find | xargs grep yourstring

(with all the usual caveats about how you have to do more than this if
you have files with spaces, etc, etc - left as an exercise for the reader)

  Réponse avec citation
Vieux 05/12/2006, 20h23   #4
William Park
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: gawk seach directory tree

baltoinfo <funnsun34@hotmail.com> wrote:
> All,
> I've seached until I've got a headache and no answers. I've found a
> couple of close ones but not exactly what I'm looking for.
>
> I'm looking for a simple cmd line or script to search a directory tree
> with all of it's files and I am looking for one word in the files.
> I've tried gawk, but can't seem to get it to traverse the sub
> directories.
> This is a just an example gawk '/hda1/ { print $0 }' /etc/mtab say I
> don't know the word is in /etc/mtab
> but I know the word is in etc. How do a search a directory.
>
> thx in advance!


man find xargs
man grep

--
William Park <opengeometry@yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
  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 13h35.


É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,15453 seconds with 12 queries