-
-
Notifications
You must be signed in to change notification settings - Fork 525
Added bash arguments ES translation #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
ebook/es/content/007-bash-arguments.md
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Argumentos en Bash | ||
|
|
||
| Puede pasar argumentos a su script de shell cuando lo ejecuta. Para pasar un argumento, solo necesita escribirlo justo después del nombre de su script. Por ejemplo: | ||
|
|
||
| ```bash | ||
| ./devdojo.com su_argumento | ||
| ``` | ||
|
|
||
| En el script, podemos usar `1ドル` para hacer referencia al primer argumento que especificamos. | ||
|
|
||
| Si pasamos un segundo argumento, estaría disponible como `2ドル` y así sucesivamente. | ||
|
|
||
| Vamos a crear un script corto llamado `argumentos.sh` como ejemplo: | ||
|
|
||
| ```bash | ||
| #!/bin/bash | ||
|
|
||
| echo "Argumento uno es 1ドル" | ||
| echo "Argumento dos es 2ドル" | ||
| echo "Argumento tres es 3ドル" | ||
| ``` | ||
|
|
||
| Guarde el archivo y hágalo ejecutable: | ||
|
|
||
| ```bash | ||
| chmod +x argumentos.sh | ||
| ``` | ||
|
|
||
| Luego ejecute el archivo y pase **3** argumentos: | ||
|
|
||
| ```bash | ||
| ./argumentos.sh perro gato pájaro | ||
| ``` | ||
|
|
||
| El resultado debería ser: | ||
|
|
||
| ```bash | ||
| Argumento uno es perro | ||
| Argumento dos es gato | ||
| Argumento tres es pájaro | ||
| ``` | ||
|
|
||
| Para hacer referencia a todos los argumentos, puede usar `$@`: | ||
|
|
||
| ```bash | ||
| #!/bin/bash | ||
|
|
||
| echo "Todos los argumentos: $@" | ||
| ``` | ||
|
|
||
| Si ejecuta el script nuevamente: | ||
|
|
||
| ```bash | ||
| ./argumentos.sh perro gato pájaro | ||
| ``` | ||
|
|
||
| El resultado debería ser: | ||
|
|
||
| ``` | ||
| Todos los argumentos: perro gato pájaro | ||
| ``` | ||
|
|
||
| Otra cosa que debe tener en cuenta es que `0ドル` se usa para hacer referencia al script en sí. | ||
|
|
||
| Esta es una excelente manera de autodestruir el archivo si lo necesita o simplemente obtener el nombre del script. | ||
|
|
||
| Por ejemplo, creemos un script que imprima el nombre del archivo y lo elimine después de eso: | ||
|
|
||
| ```bash | ||
| #!/bin/bash | ||
|
|
||
| echo "El nombre del archivo es: 0ドル y se va a autoeliminar." | ||
|
|
||
| rm -f 0ドル | ||
| ``` | ||
|
|
||
| Debe tener cuidado con la eliminación automática y asegurarse de tener una copia de seguridad de su script antes de eliminarlo automáticamente. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.