Skip to content

Instantly share code, notes, and snippets.

@ianaya89
Created October 19, 2020 20:55
Show Gist options
  • Save ianaya89/da879dd9ac3b7df316797bc10f3e8588 to your computer and use it in GitHub Desktop.
Save ianaya89/da879dd9ac3b7df316797bc10f3e8588 to your computer and use it in GitHub Desktop.
2
# mkdir
> Crear directorios
`$ mkdir my-files`
`$ mkdir my-files/txt`
`$ mkdir -p my-files/txt/new/path`
---
# touch
> Crear archivos (vacios)
`$ touch hello.txt`
---
# expansiones
`$ touch hello{1,2,3}.txt`
`$ touch hello{1..100}.txt`
`$ touch hello{1..100}.txt`
`$ touch hello{1..100..10}.txt`
`$ touch {a..z}.txt`
---
# expansiones
`$ echo {100..1}`
`$ echo {100..1..10}`
`$ echo {a..z}`
`$ echo {z..a}`
---
# wildcards
> ? (un caracter)
`$ ls hello?.txt`
> \* (un patron)
`$ ls hello*.txt`
---
# less
> Mostrar el contenido de un archivo (interactivo)
`$ less file.txt`
---
# less
- space (proxima pagina)
- 1...N (ir a linea)
- / (buscar)
- n \* N (siguiente/anterior resultado)
---
# head
> Mostrar el comienzo de un archivo
`$ head file.txt`
`$ head -n 2 file.txt`
---
# tail
> Mostrar el final de un archivo
`$ tail file.txt`
`$ tail -n 2 file.txt`
`$ tail -f file.txt`
---
# mv
> Mover archivos y directorios (o renombrarlos)
`$ mv file.txt new-file.txt`
`$ mv file.txt files/`
`$ mv file.txt files/new-file.txt`
---
# cp
> Copiar archivos y directorios
`$ cp file.txt file-copy.txt`
`$ cp -R directory directory-copy`
---
# rm
> Borrar archivos y directorios
`$ rm file.txt`
`$ rm -r directory`
`$ rm -rf directory` 🚨
---
# Nunca!
`$ rm -rf /`
---
# tar
> Agrupar archivos .tar (tape archive)
`$ tar -cf archive.tar file1.txt file2.txt file3.txt`
`$ tar -cf archive.tar file.txt directory`
`$ tar -xf archive.tar -C destination`gookl
---
# tar
> Comprimir archvos .tar.gz (tape archive)
`$ tar -zcf archive.tar.gz file.txt directory`
`$ tar -xzf archive.tar.gz -C destination`
---
# find
> Buscar archivos y directorios
`$ find . -name "file.txt"`
`$ find . -iname "file.txt"`
`$ find . -name "*.txt"`
---
# find
> Buscar por tipo (f, d, i, c, b)
`$ find . -name "*.txt" -type f`
`$ find . -name "*.txt" -type d`
---
# diff
> Ver diferencias entre archivos
`$ diff file1.txt file2.txt`
`$ diff -u file1.txt file2.txt`
---
# wc
> Contar lineas, palabras y bytes
`$ wc file.txt`
`$ wc -w file.txt`
`$ wc -l file.txt`
`$ wc -c file.txt`
---
# date
> Mostrar la fecha
`$ date`
`$ date +'%Y-%m-%d %H:%M:%S'`
---
# cal
> Mostrar calendario
`$ cal`
`$ cal -3`
`$ cal 2021`
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment