Use word count to make sure you’re getting the length you expected.
cat /dev/urandom| tr -dc 'a-zA-Z0-9-!@#$%^&*()+{}|:<>?=' | fold -w 1048 | head -n1 | wc -m
And use this to actually fetch the long string.
cat /dev/urandom| tr -dc 'a-zA-Z0-9-!@#$%^&*()+{}|:<>?=' | fold -w 1048 | head -n1 | wc -m
Here’s a much simpler example, in case you just want a quick four digit number:
cat /dev/urandom| tr -dc ’0-9′ | fold -w 4 | head -n1