I've found more than few things on here to help me as I'm learning to code in Bash and they all come close but not quite.
I need to take an input of a positive integer and print out on a single line down to one, all separated by commas, without a comma at the end of the last variable.
This is what I have so far:
#!/bin/bash
#countdown
read -p "Enter a Number great than 1: " counter
until ((counter < 1)); do
echo -n ",$counter"
((counter--))
done
It almost works out but I can't figure out how to prevent the comma in front and not have it behind the last variable.
EDIT: You guys are AMAZING. Poured over this book and learned more in ten minutes here than I did with an hour there.
So is there some sort of command I could use to ensure it was only one number entered and ensure it had to be positive?
Some way to put an if statement on the read to ensure its <= 1 and only one character?
I only have a background in some basic C coding, so I have the basics but translating them to BASH is harder than expected