Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Cercare una parola dentro ad un file
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian)
View previous topic :: View next topic  
Author Message
alkaid
Guru
Guru


Joined: 21 Feb 2004
Posts: 322
Location: Padova

PostPosted: Sun Apr 24, 2005 8:56 am    Post subject: Cercare una parola dentro ad un file Reply with quote

avrei bisogno di un suggerimento :oops:
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
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31467
Location: here

PostPosted: Sun Apr 24, 2005 9:06 am    Post subject: Reply with quote

Il comando puo' essere
Code:
find . -name "*" | xargs grep "parola"

_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
Dhaki
Guru
Guru


Joined: 16 Jun 2004
Posts: 325
Location: Ticino - CH

PostPosted: Sun Apr 24, 2005 9:06 am    Post subject: Reply with quote

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
View user's profile Send private message
skakz
Guru
Guru


Joined: 03 Jul 2004
Posts: 380
Location: Ischia/Napoli/Italia/Terra

PostPosted: Sun Apr 24, 2005 9:10 am    Post subject: Reply with quote

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
View user's profile Send private message
alkaid
Guru
Guru


Joined: 21 Feb 2004
Posts: 322
Location: Padova

PostPosted: Sun Apr 24, 2005 9:19 am    Post subject: Reply with quote

grazie mille :wink:
Back to top
View user's profile Send private message
GiRa
l33t
l33t


Joined: 07 Apr 2005
Posts: 717

PostPosted: Sun Apr 24, 2005 12:02 pm    Post subject: Reply with quote

Mi pare più elegante:
Code:
find /tua/directory/di/ricerca -iname "*" -exec grep -H "stringa cercata" {} \;
Back to top
View user's profile Send private message
comio
Advocate
Advocate


Joined: 03 Jul 2003
Posts: 2191
Location: Taranto

PostPosted: Sun Apr 24, 2005 12:16 pm    Post subject: Reply with quote

scusate... ma un semplice:
Code:

grep -R "PAROLADACERCARE" DIRECTORY

Per cercare nella directory corrente:
Code:

grep -R "PAROLA" .


ciao
_________________
RTFM!!!!

e

http://www.comio.it
:)
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31467
Location: here

PostPosted: Sun Apr 24, 2005 1:13 pm    Post subject: Reply with quote

comio wrote:
scusate... ma un semplice:

Naaaa troppo semplice :P . Sinceramente ho sempre usato find con grep... ora usero' questa
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
lopio
Veteran
Veteran


Joined: 22 Dec 2003
Posts: 1161
Location: savona, Italy

PostPosted: Sun Apr 24, 2005 2:00 pm    Post subject: Reply with quote

fedeliallalinea wrote:
comio wrote:
scusate... ma un semplice:

Naaaa troppo semplice :P . Sinceramente ho sempre usato find con grep... ora usero' questa

anche io usavo il find ma sta opzione grep non e' male davvero :wink:
Back to top
View user's profile Send private message
GiRa
l33t
l33t


Joined: 07 Apr 2005
Posts: 717

PostPosted: Mon Apr 25, 2005 8:11 am    Post subject: Reply with quote

@comio: da quel che ho capito si parla di cercare in un albero di directory.
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31467
Location: here

PostPosted: Mon Apr 25, 2005 8:18 am    Post subject: Reply with quote

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
View user's profile Send private message
alkaid
Guru
Guru


Joined: 21 Feb 2004
Posts: 322
Location: Padova

PostPosted: Mon Apr 25, 2005 11:27 am    Post subject: Reply with quote

si, dovevo cercare in tutte le sottodir
ciao
Back to top
View user's profile Send private message
GiRa
l33t
l33t


Joined: 07 Apr 2005
Posts: 717

PostPosted: Mon Apr 25, 2005 2:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31467
Location: here

PostPosted: Mon Apr 25, 2005 3:34 pm    Post subject: Reply with quote

Fino ad ora no
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
gutter
Bodhisattva
Bodhisattva


Joined: 13 Mar 2004
Posts: 7162
Location: Aarau, Aargau, Switzerland

PostPosted: Tue Apr 26, 2005 7:33 am    Post subject: Reply with quote

comio wrote:
scusate... ma un semplice:
Code:

grep -R "PAROLADACERCARE" DIRECTORY



L'ottimo globale del problema in questione ;)
_________________
Registered as User #281564 and Machines #163761
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum