Im attempting to create a function that when called it will create as many files as the value of a parameter given. For instance, if I call it :
ejercicio_VI file 4
It will create file1 and file2 and file3 and so on...
This obviously works manually but it seems it does not work correctly within a function.
Why is my function not expanding the filenames correctly?
ejercicio_VI() {
if [[ $# -ne 2 ]]
then
echo "Esta funcion solo acepta dos parametros"
return 255;
fi
if [[ ! $1 =~ ^[a-zA-Z]+$ ]]
then
echo "El primer parametro debe ser una string que matchee con esta expresion regular : ^[a-zA-Z]+$"
echo "Asi no creamos archivos basura :P "
return 255;
fi
if [[ ! $2 =~ ^[1-9]([1-9])?+$ ]]
then
echo "El segundo parametro debe ser un numero"
return 255;
fi
touch "$1"{1.."$2"}
}