0

I am trying to make a simple bash script which prints out the path of current song in MPD.

while [ 1 ]
do
    mpc idle
    track=$(mpc current | awk -F " - " '{print $2}')
    echo $track

    path_to_track=$(mpc search title "$track")
    echo $path_to_track

    "$path_to_track" >> /home/noob/MPDPlaylist/testplaylist.m3u

done

Now, the problem is as soon as my script tries to appenf the value of path_to_track to the file it generates the below error

player
Skin To Bone
Linkin Park/Living Things(2012)/09 - Linkin Park - Skin To Bone.mp3
test.sh: line 8: Linkin Park/Living Things(2012)/09 - Linkin Park - Skin To Bone.mp3: No such file or directory

Now, what am I doing wrong here. As you can see in the above code I already tried adding double quotes .

1 Answer 1

2

Right now you're trying to execute your mp3 files. You probably wanted to echo that:

echo "$path_to_track" >> /home/noob/MPDPlaylist/testplaylist.m3u
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, it worked. Actually I tried it with echo but it was not working may be I messed something.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.