#elimina el proceso y retorna 0 si fue exitoso, 1 si falló. los parámetros incluidos serán #tratados como uno solo
#uso: matar "proceso"
function matar {
if [ "$*" == "" ]; then
echo "Falta el nombre del proceso a eliminar"
else
local ps=$(ps aux | grep "$*" | grep -v grep | awk '{print $1, $2, $11}')
local pid=$(ps aux | grep "$*" | grep -v grep | awk '{print $2}')
echo "$ps"
kill -9 $pid
local ct=$?
echo $ct
fi
}
Code:
#dice los kb de los archivos de la carpeta actual, ampliable a cálculo de Mb
# uso: megas
function megas {
let ct=0
for i in $(ls -la | grep "^-" | cut -c25-31)
do
let sumBytes=($sumBytes + $i)
done
echo "$((sumBytes/1024)) Kbytes"
sumBytes=$ct
}
Code:
#muestra los archivos con permiso de ejecución dentro de un diretorio.
#uso: ejecutables /directorio/
function ejecutables {
all=$(ls -l $1 | grep "^-")
for ejecutables in $all
do
ruta_fichero="$1$ejecutables"
if [ -x $ruta_fichero ]; then
echo $ruta_fichero
fi
done
}
Estas funciones las colocas en el archivo de configuración de bash y las tendrás disponibles automáticamente, al iniciar la terminal nuevamente o sino se carga el fichero de configuración con:
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 You cannot attach files in this forum You can download files in this forum