Búsquedes: diferència entre les revisions

De WikiMar
Salta a la navegació Salta a la cerca
Cap resum de modificació
Línia 16: Línia 16:


== Find ==
== Find ==
Busca a la carpeta actual i també a subcarpetes:
=== Busca a la carpeta actual i també a subcarpetes: ===
  find . -name PART_NOM_FITXER*
  find . -name PART_NOM_FITXER*
Busca a tot el sistema:
=== Busca a tot el sistema: ===
  find / -name PART_NOM_FITXER*
  find / -name PART_NOM_FITXER*
Buscar també links:
=== Buscar també links: ===
  find . -iname PART_NOM_FITXER*
  find . -iname PART_NOM_FITXER*
Buscar característiques:
=== Buscar característiques: ===
  find . -size +1500
  find . -size +1500




Buscar fitxers d'un usuari:
=== Buscar fitxers d'un usuari: ===
  find . -user <userid>
  find . -user <userid>


Executar comandes sobre fitxers trobats:
=== Executar comandes sobre fitxers trobats: ===
  find /var/log -name "*.txt" -type f -exec chmod 755 {} \;
  find /var/log -name "*.txt" -type f -exec chmod 755 {} \;
This command changes the permissions of all files with a name ending in .txt in the directory /var/music. The action is carried out by specifying the option -exec chmod 755 {} \; in the command.
This command changes the permissions of all files with a name ending in .txt in the directory /var/music. The action is carried out by specifying the option -exec chmod 755 {} \; in the command.
Línia 35: Línia 35:




Buscar fitxers que continguin una cadena:
=== Buscar fitxers que continguin una cadena: ===
  find /tmp -exec grep "search string" '{}' /dev/null \; -print
  find /tmp -exec grep "search string" '{}' /dev/null \; -print
o bé
o bé
Línia 41: Línia 41:
o filtrant el tipus de fitxers
o filtrant el tipus de fitxers
  find . -name *.html -exec grep 'CADENA' {} \;
  find . -name *.html -exec grep 'CADENA' {} \;


== Buscar continguts amb Grep ==
== Buscar continguts amb Grep ==
  grep -r "CADENA" /carpeta
  grep -r "CADENA" /carpeta

Revisió del 11:46, 1 jul 2008

Locate

Actualitzar base de dades amb fitxers del sistema:

updatedb

Buscar fitxer ràpidament:

locate NOM_FITXER

Which

which NOM_FITXER

Ls

(Buscar a la carpeta actual nomes)

ls -las NOM_FITXER
ls -las PART_NOM_FITXER*


Find

Busca a la carpeta actual i també a subcarpetes:

find . -name PART_NOM_FITXER*

Busca a tot el sistema:

find / -name PART_NOM_FITXER*

Buscar també links:

find . -iname PART_NOM_FITXER*

Buscar característiques:

find . -size +1500


Buscar fitxers d'un usuari:

find . -user <userid>

Executar comandes sobre fitxers trobats:

find /var/log -name "*.txt" -type f -exec chmod 755 {} \;

This command changes the permissions of all files with a name ending in .txt in the directory /var/music. The action is carried out by specifying the option -exec chmod 755 {} \; in the command. For every file whose name ends in .txt, the command chmod 755 {} is executed replacing {} with the name of the file. The semicolon (backslashed to avoid the shell interpreting it as a command separator) indicates the end of the command.


Buscar fitxers que continguin una cadena:

find /tmp -exec grep "search string" '{}' /dev/null \; -print

o bé

find /tmp -exec grep -H "search string" '{}' \; -print

o filtrant el tipus de fitxers

find . -name *.html -exec grep 'CADENA' {} \;

Buscar continguts amb Grep

grep -r "CADENA" /carpeta