I just started using bash so I hope the answer is not obvious. I have a file called playlists.txt that looks like this:
- ChilledDubstep PLYNrAD9Jn2WDwRrS_Uw6UR55K-c_s6EH4
- Classical PLYNrAD9Jn2WDWZFpIG3a2tkOBtdeNAbc6
- ChilledOut PLYNrAD9Jn2WCfrUCoS22kn3pBX1XUFinE
- SlickSlickSound PLYNrAD9Jn2WDmpu3gNVxIVO8bAiOcQkx7
- Albums,concerts PLYNrAD9Jn2WD3BI8o5VjmSbhZgfYh5zaX
I want to assign the first string of each line to $name and the second string to $hash, then send it to script.sh and do this recursively for every line, knowing that the number of lines might increase in the future.
I wrote this but it does not work: using this ->How to split one string into multiple variables in bash shell?
while read name hash
do
sh script.sh "$name" "$hash"
done < playlists.txt
Whats should I be doing instead? Thank you in advance.
EDIT: Thanks guys, so I changed it to this, it is easier to read. I thought, it was going to resolve my errors, but there are still there...damn it. So basically, in script.sh, here is the first part:
cd ~/Music/Youtube\ Playlist/Playlists/$name
mv $HOME/Music/Youtube\ Playlist/Playlists/$name/TextRecords/lastoutput.txt $HOME/Music/Youtube\ Playlist/Playlists/lastoutput.txt
However, the shell returns the error:
mv: cannot stat `/home/kabaka/Music/Youtube Playlist/Playlists//TextRecords/lastoutput.txt': No such file or directory
That means that where there should the name of a playlist, there is nothing. Do you have any idea why? Is it because $name in my current script and $name in the script above are not the same? Notice that I have the same thing happening for $hash, which should appear in an url but is just blank