Working with lines or variables that have spaces or special characters

Example:

while read line
do
stat -c %G $line
done < somefile.txt

The problem is that inside somefile.txt lines can have any symbol allowed as file name, like (). Even with spaces, it splits the words.

somefile.txt:

dira/my first jump.avi
dirb/surf video (1080p).mkv

Hi,

Try:

stat -c %G "$line"
1 Like

Thanks worked!