Skip to content

Instantly share code, notes, and snippets.

@elcascarudo-dev
Created May 7, 2020 15:38
Show Gist options
  • Save elcascarudo-dev/bf79241e49d0ec6da017752f42805cd9 to your computer and use it in GitHub Desktop.
Save elcascarudo-dev/bf79241e49d0ec6da017752f42805cd9 to your computer and use it in GitHub Desktop.
For linea de comando Linux
# Estructura
for [variable] in [lista a recorrer]; do [comandos a ejecutar]; done
# Ejemplo
-- Listo los elementos que devuelve el "ls"
for x in $(ls); do echo $x; done
-- Defijo si es archivo o directorio lo que devuelve el "ls"
for x in $(ls); do if [[ -f $x ]]; then echo "Archivo -> $x"; else echo "Directorio -> $x"; fi; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment