Using shell script, I am creating a script.sh
file that automates some tasks for me. In it I need to sort a file from the current directory to perform some tasks. I am raffling the file with the command below:
shuf -n1 -e $(ls)
The code works perfectly when the file name does not contain white space (ex: relatorio.pdf
). However, for files with whitespace (eg relatorio mensal.pdf
), the draw ends up breaking the filename (in my example, it is relatorio
and mensal.pdf
).
I would like the shuf
command to draw and always return the full name of the file, even if it contains white space. Does anyone know how to do this?