grep

El comando grep permite buscar en uno o más archivos, o en la entrada estándar, las líneas correspondientes a un filtro.

La sintaxis general de grep es:

grep opción(es) filtro archivo(s) 

Al utilizar la entrada estándar para filtrar la salida del comando ps, se limita el resultado a las líneas que contienen una cadena de caracteres en particular; por ejemplo, para encontrar rápidamente el PID del proceso sleep:

$ ps -ef  
UID        PID  PPID  C STIME TTY          TIME CMD  
root         1     0  0 09:45 ?        00:00:02 /sbin/init  
root         2     0  0 09:45 ?        00:00:00 [kthreadd]  
root         3     2  0 09:45 ?        00:00:00 [ksoftirqd/0]  
root         4     2  0 09:45 ?        00:00:00 [migration/0]  
root         5     2  0 09:45 ?        00:00:00 [watchdog/0]  
root         6     2  0 09:45 ?        00:00:00 [events/0]  
...  
root      1528     1  0 09:46 ?        00:00:00 crond  
root      1542     1  0 09:46 ?        00:00:00...
couv_RIT6BLIN.png

 

41-logo_abonnement.svg
Anterior
find
Siguiente
cut