Notas de Luis

Podemos comprobar si un fichero existe o no utilizando el comando test -f de esta forma:

#!/bin/bash
 
# Verificar si el archivo script_bellisimo.py existe y es un archivo regular
 
if test -f script_bellisimo.py; then
  echo "El archivo existe"
else
  echo "El archivo no existe"
fi

Y este es el resultado:

computing/linux/commandline/test_f_para_comprobar_existencia_de_ficheros.txt · Última modificación: por 127.0.0.1