I'm working on a bash script to sync my music to my phone, allowing me to choose between lossless and lossy formats, as well as different codecs and bitrates. I'm trying to mimic a feature from iTunes, but I'm encountering a parse error. The error message says: `Parse error, at least 3 arguments were expected, only 1 given in string '/Test/Bennett/Vois sur ton chemin (Techno Mix)/01 Vois sur ton chemin (Techno Mix).flac'`. I've included a link to the full output for more context: https://pastebin.com/raw/XW69BbiQ. Below is the script I'm using.
3 Answers
Yeah, that error usually happens when the script is not recognizing the input correctly. Make sure that the path and arguments you are providing are formatted correctly. Debug with `set -x` to trace what variables are being set and how they're being used in the commands.
It seems like you're running into issues due to how the `find` command and `while` loop are interacting. When you pipe the output of `find` to `while`, it creates a subshell, which can mess with variable handling. Instead, you might consider using a `for` loop: `for file in "".flac; do ; done. This should help you avoid those scoping issues!
To format your script properly, you should add four spaces before each line of code and leave a blank line before it. This can make it easier for others to read and understand your code when you post it online. Just an extra tip!
That's a good point! I think using a `for` loop would definitely help keep the variable scope within your main script.