Com gsed você não precisa do extra '', apenas com o padrão OSX sed. Experimente:
SED=/usr/bin/sed
Ou:
SEDOPTS=(-i)
Eu tenho um script Bash que realiza uma substituição simples no OS X. Aqui está o caso reduzido:
mkdir vs2005-dynamic
cp cryptdll.vcproj cryptest.sln cryptest.vcproj cryptlib.vcproj dlltest.vcproj vs2005-dynamic/
cd vs2005-dynamic
...
SED=/opt/local/bin/gsed
SEDOPTS=(-i "")
...
PROJ_FILES=($(find $PWD -name "*.vcproj"))
for pf in "${PROJ_FILES[@]}"; do
"$SED" "${SEDOPTS[@]}" -e 's|RuntimeLibrary="0"|RuntimeLibrary="2"|g' "$pf"
"$SED" "${SEDOPTS[@]}" -e 's|RuntimeLibrary="1"|RuntimeLibrary="3"|g' "$pf"
done
Quando eu o executo com bash -x
, ele imprime oito erros. Não consigo descobrir de onde os erros estão vindo. A pesquisa pelo erro fornece um hit , mas eu não vejo a solução.
Onde está "gsed: não pode ler: Nenhum arquivo ou diretório" vindo de?
Abaixo, <full path>
é /Users/<username>/<project name>/vs2005-dynamic/
. Não há espaços no nome do caminho.
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="0"|RuntimeLibrary="2"|g' <full path>/cryptdll.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="1"|RuntimeLibrary="3"|g' <full path>/cryptdll.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ for pf in '"${PROJ_FILES[@]}"'
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="0"|RuntimeLibrary="2"|g' <full path>/cryptest.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="1"|RuntimeLibrary="3"|g' <full path>/cryptest.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ for pf in '"${PROJ_FILES[@]}"'
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="0"|RuntimeLibrary="2"|g' <full path>/cryptlib.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="1"|RuntimeLibrary="3"|g' <full path>/cryptlib.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ for pf in '"${PROJ_FILES[@]}"'
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="0"|RuntimeLibrary="2"|g' <full path>/dlltest.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="1"|RuntimeLibrary="3"|g' <full path>/dlltest.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
Tags bash sed shell-script