View previous topic :: View next topic |
Author |
Message |
alkaid Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/gallery/Sonic/1.png)
Joined: 21 Feb 2004 Posts: 322 Location: Padova
|
Posted: Sun Apr 24, 2005 8:56 am Post subject: Cercare una parola dentro ad un file |
|
|
avrei bisogno di un suggerimento
ho bisogno di sapere come si fa a trovare tutti i files che contengono una data parola, che comando posso usare?
grazie |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
fedeliallalinea Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
![](images/avatars/161653968057192eb39329f.jpg)
Joined: 08 Mar 2003 Posts: 31467 Location: here
|
Posted: Sun Apr 24, 2005 9:06 am Post subject: |
|
|
Il comando puo' essere
Code: | find . -name "*" | xargs grep "parola" |
_________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Dhaki Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/66168532540f5109c48086.png)
Joined: 16 Jun 2004 Posts: 325 Location: Ticino - CH
|
Posted: Sun Apr 24, 2005 9:06 am Post subject: |
|
|
Puoi fare con un comando del tipo:
Code: | for i in *; do PAROLA=$( grep "parola_da_cercare" "$i") && if [ -n "$PAROLA" ]; then echo -e $i\n; fi; done |
Mettendo tutti i file che vuoi cercare nella cartella dove esegui questo comando. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
skakz Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/26103121844b6543b90f6a.gif)
Joined: 03 Jul 2004 Posts: 380 Location: Ischia/Napoli/Italia/Terra
|
Posted: Sun Apr 24, 2005 9:10 am Post subject: |
|
|
se questi file sono tutti contenuti in una directory puoi dare un
Code: |
grep parola * # se ci sono anche sottodirectory puoi mettere */*/* per esempio..
|
se invece sono sparsi in varie directory puoi provare con
Code: |
find / | xargs grep parola
|
_________________ Linux Registered User n.340423
Linux User Group Ischia
www.tush.it |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
alkaid Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/gallery/Sonic/1.png)
Joined: 21 Feb 2004 Posts: 322 Location: Padova
|
Posted: Sun Apr 24, 2005 9:19 am Post subject: |
|
|
grazie mille ![Wink :wink:](images/smiles/icon_wink.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
GiRa l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
Joined: 07 Apr 2005 Posts: 717
|
Posted: Sun Apr 24, 2005 12:02 pm Post subject: |
|
|
Mi pare più elegante: Code: | find /tua/directory/di/ricerca -iname "*" -exec grep -H "stringa cercata" {} \; |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
comio Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/761284344415a971047e47.gif)
Joined: 03 Jul 2003 Posts: 2191 Location: Taranto
|
Posted: Sun Apr 24, 2005 12:16 pm Post subject: |
|
|
scusate... ma un semplice:
Code: |
grep -R "PAROLADACERCARE" DIRECTORY
|
Per cercare nella directory corrente:
ciao _________________ RTFM!!!!
e
http://www.comio.it
![Smile :)](images/smiles/icon_smile.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
fedeliallalinea Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
![](images/avatars/161653968057192eb39329f.jpg)
Joined: 08 Mar 2003 Posts: 31467 Location: here
|
Posted: Sun Apr 24, 2005 1:13 pm Post subject: |
|
|
comio wrote: | scusate... ma un semplice: |
Naaaa troppo semplice . Sinceramente ho sempre usato find con grep... ora usero' questa _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
lopio Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/gallery/Southpark/avatar22.gif)
Joined: 22 Dec 2003 Posts: 1161 Location: savona, Italy
|
Posted: Sun Apr 24, 2005 2:00 pm Post subject: |
|
|
fedeliallalinea wrote: | comio wrote: | scusate... ma un semplice: |
Naaaa troppo semplice . Sinceramente ho sempre usato find con grep... ora usero' questa |
anche io usavo il find ma sta opzione grep non e' male davvero ![Wink :wink:](images/smiles/icon_wink.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
GiRa l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
Joined: 07 Apr 2005 Posts: 717
|
Posted: Mon Apr 25, 2005 8:11 am Post subject: |
|
|
@comio: da quel che ho capito si parla di cercare in un albero di directory. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
fedeliallalinea Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
![](images/avatars/161653968057192eb39329f.jpg)
Joined: 08 Mar 2003 Posts: 31467 Location: here
|
Posted: Mon Apr 25, 2005 8:18 am Post subject: |
|
|
GiRa wrote: | @comio: da quel che ho capito si parla di cercare in un albero di directory. |
Si infatti -R fa in modo recursivo nelle sotto directory _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
alkaid Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/gallery/Sonic/1.png)
Joined: 21 Feb 2004 Posts: 322 Location: Padova
|
Posted: Mon Apr 25, 2005 11:27 am Post subject: |
|
|
si, dovevo cercare in tutte le sottodir
ciao |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
GiRa l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
Joined: 07 Apr 2005 Posts: 717
|
Posted: Mon Apr 25, 2005 2:36 pm Post subject: |
|
|
fedeliallalinea wrote: | GiRa wrote: | @comio: da quel che ho capito si parla di cercare in un albero di directory. |
Si infatti -R fa in modo recursivo nelle sotto directory |
Mai ricevuto l'errore di grep Code: | Argument list too long | o qualcosa del genere? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
fedeliallalinea Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
![](images/avatars/161653968057192eb39329f.jpg)
Joined: 08 Mar 2003 Posts: 31467 Location: here
|
Posted: Mon Apr 25, 2005 3:34 pm Post subject: |
|
|
Fino ad ora no _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
gutter Bodhisattva
![Bodhisattva Bodhisattva](/images/ranks/rank-bodhisattva.gif)
![](images/avatars/67030318436dd16c1dd5e.jpg)
Joined: 13 Mar 2004 Posts: 7162 Location: Aarau, Aargau, Switzerland
|
Posted: Tue Apr 26, 2005 7:33 am Post subject: |
|
|
comio wrote: | scusate... ma un semplice:
Code: |
grep -R "PAROLADACERCARE" DIRECTORY
|
|
L'ottimo globale del problema in questione ![Wink ;)](images/smiles/icon_wink.gif) _________________ Registered as User #281564 and Machines #163761 |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|