I'm trying to get the number of columns or lines of my terminal but the variables COLUMNS / LINES are always empty

COLUMNS and LINES are set by BASH only in interactive shells; they do not work in a script. Instead you can use:

COLUMNS=$(tput cols)
LINES=$(tput lines)

Bash automatically updates the COLUMNS and LINES variables when an interactive shell is resized. If you're setting the variables in a script and you want them to be updated when the terminal is resized, i.e. upon receipt of a SIGWINCH, you can set a trap yourself:

trap 'COLUMNS=$(tput cols) LINES=$(tput lines)' WINCH

You can also set the shell as interactive in the script's shebang:

 #!/bin/bash -i
 echo $COLUMNS

Though not the best practice, it's not too uncommon for scripts to test for the -i option to determine whether a shell is interactive. There is no completely foolproof way to test for this, so some scripts may break as a result. Also, running with -i sources .bashrc, and sets various options such as job-control which may have unintended side-effects. Though you can technically set -i in the middle of a script, it has no effect on the setting of COLUMNS and LINES -- -i must be set when Bash is first invoked.

If COLUMNS / LINES aren't being updated even when running an interactive shell, ensure that the checkwinsize shopt option is enabled.

tput, of course, requires a terminal. According to POSIX, if stdout is not a tty, then results are unspecified, and that stdin is unused, though some implementations may try using it anyway. On this Gentoo Linux system (and apparently at least some other Linuxes), at least one of stdout or stderr must be a tty, otherwise tput just returns some default value (here it's "80").