Búsquedes: diferència entre les revisions
Cap resum de modificació |
Cap resum de modificació |
||
Línia 29: | Línia 29: | ||
find . -user <userid> | 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. | |||
Revisió del 11:45, 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