Created
September 10, 2015 17:57
-
-
Save jthmiranda/0cd08d360d961832198e to your computer and use it in GitHub Desktop.
{,} en los comandos de Linux y Unix?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Por lo general utilizo esto {,} cuando necesito crear archivos numerados: archivo1, archivo2, archivo”n”: | |
> [ rafael ] ~ $ touch archivo{1..3}.log | |
> [ rafael ] ~ $ ls -lt | |
total 0 | |
-rw-r--r-- 1 rafael 0xl337 0B Nov 4 00:52 archivo1.log | |
-rw-r--r-- 1 rafael 0xl337 0B Nov 4 00:52 archivo2.log | |
-rw-r--r-- 1 rafael 0xl337 0B Nov 4 00:52 archivo3.log | |
> [ rafael ] ~ $ | |
Otra de las utilidades que le eh encontrado es para cambiar de nombre o extensión a los archivos y así cómo copiarlos: | |
> [ rafael ] ~ $ touch logs.txt{,.bak} | |
> [ rafael ] ~ $ ls -lt | |
total 0 | |
-rw-r--r-- 1 rafael 0xl337 0B Nov 4 01:02 logs.txt | |
-rw-r--r-- 1 rafael 0xl337 0B Nov 4 01:02 logs.txt.bak | |
> [ rafael ] ~ $ | |
De esta forma nos ahorramos tiempo en cp/mv logs.txt logs.texto. Existen varias formas para sacarle provecho: | |
> [ rafael ] ~ $ touch logs.texto | |
> [ rafael ] ~ $ ls | |
logs.texto | |
> [ rafael ] ~ $ mv logs.{texto,txt} | |
> [ rafael ] ~ $ ls | |
logs.txt | |
> [ rafael ] ~ $ cp logs.txt{,.texto} | |
> [ rafael ] ~ $ ls | |
logs.txt logs.txt.texto | |
> [ rafael ] ~ $ | |
$ echo bucio.{mx,com.mx} | xargs -n 1 host -v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment