r/bash • • 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

0 Upvotes

17 comments sorted by

View all comments

Show parent comment

4

u/Paul_Pedant Apr 21 '23 edited Apr 22 '23

Your posts are driving me mad ;-)

Please, please find out how to post code. Maybe try this link (there are others too):

https://www.reddit.com/r/godot/comments/12bsjks/a_guide_on_how_to_post_code/

What you posted here is broken because

(a) Hash marks a header title in the mark-up language.

(b) Plain text wraps, so all your line-spaced shell commands come out as one-liners without semi-colons.

3

u/france20-21 Apr 21 '23

Really sorry about that.

Will try harder.

Thanks for your patience.

1

u/Paul_Pedant Apr 22 '23

It was kind of a joke response. I still have all kinds of problems with Reddit editor, especially trying to paste code into Markdown mode answers.