Yes, obviously, you can't "escape the space" when the filename is contained inside a variable.
Secondly, you really don't need to mess with IFS. All you really need to do is to quote the variable reference that is passed to omxplayer. In fact, when shell scripting, the wise word is that you should
*always* quote your variables (that is, wrap them in " marks) unless you have a specific reason to do otherwise (and those specific reasons are rare).
Thirdly, there is no reason to use 'sudo' when invoking omxplayer.
Here's how I would do this:
Code: Select all
#!/bin/bash
cd "/path/to/the place where/the audio files/are kept"
while :;do
ls | shuf | while read;do
omxplayer -whatever_options_you_need "$REPLY"
done
done
If this post appears in the wrong forums category, my apologies.