I get the following error:
./cmp_em.sh: line 72: syntax error near unexpected token `('
./cmp_em.sh: line 72: `cmp '/Volumes/Macintosh HD/Users/adpacifico/Music/iTunes/iTunes Media/Music/Alpha Blondy/Merci/01 Wari Feat. Saian Supa Crew (Samuel And Leeroy).mp3' '/Volumes/MacBook Pro Internal HD/Users/alpo/Music/iTunes/iTunes Media/Music/Alpha Blondy/Merci/01 Wari Feat. Saian Supa Crew (Samuel And Leeroy).mp3''
only when the script is running, not from the command line.
Als-MacBook-Pro:test alpo$ echo $SHELL
/bin/bash
Als-MacBook-Pro:test alpo$ /bin/bash --version
GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin14)
Copyright (C) 2007 Free Software Foundation, Inc.
Als-MacBook-Pro:test alpo$ head -n 2 cmp_em.sh
#!/bin/bash
cmp '/Volumes/Macintosh HD/Users/adpacifico/Music/iTunes/iTunes Media/Music/.DS_Store' '/Volumes/MacBook Pro Internal HD/Users/alpo/Music/iTunes/iTunes Media/Music/.DS_Store'
Thoughts as to why?
In response to a request for more of the script, here are the line that generates the error and the the lines that precede and follow it:
cmp '/Volumes/Macintosh HD/Users/adpacifico/Music/iTunes/iTunes Media/Music/Aloe Blacc/I Need A Dollar 12_/01 I Need A Dollar.mp3' '/Volumes/MacBook Pro Internal HD/Users/alpo/Music/iTunes/iTunes Media/Music/Aloe Blacc/I Need A Dollar 12_/01 I Need A Dollar.mp3'
cmp '/Volumes/Macintosh HD/Users/adpacifico/Music/iTunes/iTunes Media/Music/Alpha Blondy/Merci/01 Wari Feat. Saian Supa Crew (Samuel And Leeroy).mp3' '/Volumes/MacBook Pro Internal HD/Users/alpo/Music/iTunes/iTunes Media/Music/Alpha Blondy/Merci/01 Wari Feat. Saian Supa Crew (Samuel And Leeroy).mp3'
cmp '/Volumes/Macintosh HD/Users/adpacifico/Music/iTunes/iTunes Media/Music/Alpha Blondy/Merci/02 Who Are You Feat. Ophelie Winter.mp3' '/Volumes/MacBook Pro Internal HD/Users/alpo/Music/iTunes/iTunes Media/Music/Alpha Blondy/Merci/02 Who Are You Feat. Ophelie Winter.mp3'
Please note, the original error message said error on line 72 because I had deleted the shebang shell invocation and run it using the source command, but as the error message originally posted indicated, the error is with the middle of the three lines above. The error persists whether or not the script runs using the source command or the shebang shell invocation.
Explanation was an escaped single quote in a filename preceding the line in question: Bash manual says "A single quote may not occur between single quotes, even when preceded by a backslash."
Aucun commentaire:
Enregistrer un commentaire