Last active
January 26, 2023 18:43
-
-
Save neverkas/ed22169ec0781f397271eb9cea975d84 to your computer and use it in GitHub Desktop.
Dividir un archivo en varias partes de un tamaño específico
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
# Nota: renombrar el archivo dividir-archivo.mk por Makefile | |
# | |
# Ejemplo de uso en un emulador de terminal de Linux | |
# | |
# make help | |
# make dividir-archivo NAME=patrones-en-java.pdf | |
# make unir-partes NAME=patrones-en-java.pdf | |
MAX_SIZE=5MB | |
##@ Comandos | |
dividir-archivo: ## Comando Split, Ex. dividir-archivo NAME=nombre-libro.pdf | |
$(info Dividiendo el archivo..) | |
@split -b $(MAX_SIZE) $(NAME) $(NAME). && \ | |
echo "Tarea terminada! :)" | |
unir-partes: ## Comando Join, Ex. unir-partes NAME=nombre-libro.pdf | |
$(info Uniendo las partes del archivo..) | |
@cat $(NAME).?? > $(NAME) && \ | |
rm -v $(NAME).?? && \ | |
echo "Tarea terminada! :)" | |
##@ Utilidades | |
h help: ## Mostrar menú de ayuda | |
@awk 'BEGIN {FS = ":.*##"; printf "\nOpciones para usar:\n make \033[36m\033[0m\n"} /^[$$()% 0-9a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | |
.PHONY: dividir-archivo unir-partes h help |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment