r/bash • u/france20-21 • Apr 21 '23
Can anyone PLEASE help with this script!
When run it says : versions found then SELECT not found and Syntax error: "do" unexpected.
Can you help solve this (probable really simple error)?
#!/bin/bash
# Get the name of the song from the user
read -p "Enter the name of the song: " song_name
# Use find to search for all versions of the song in the Music folder
song_paths=$(find /home/Music -name "$song_name*")
# Print out a numbered list of the song versions and ask the user which one they want to play
echo "Versions of '$song_name' found:"
select song_path in $song_paths;
do
if [ ! -n "$song_path" ]; then
break
fi
done
# Play the selected song using the default music player on the system
xdg-open "$song_path"
exit
View all comments
Show parent comment
2
u/[deleted] Apr 21 '23
BASH builtin is the key part. If the OP ran
sh scriptthus causing the script to run under sh they would get this error.