Как сделать функции видимыми для скриптов Bash?
У меня есть функция под названием groovy, определенная в моем .bashrc.
У меня есть этот скрипт, где я хочу использовать Groovy.
Это говорит./batch.sh: line 7: groovy: command not found
Хотя я и исходник .bashrc в начале скрипта.
Чего мне не хватает?
batch.sh
#!/usr/bin/env bash
source ~/.bashrc
for file in *.html;
do
name="${file%.html}"
groovy "$name.html" "uncached/$name.mp3"
done;
часть .bashrc
function groovy {
sed -n '/<pre>/,/<\/pre>/p' "$1" | replace '<pre>' '' '</pre>' '' | hextomp3 - "$2"
}
function hextomp3 {
echo "in $1"
echo "out $2"
echo "cut -c10-74 $1 | xxd -r -p - $2"
cut -c10-74 "$1" | xxd -r -p - "$2"
}
выход :
chaouche@karabeela ~/DOWNLOADS/MUSIQUE $ ./batch.sh
./batch.sh: line 6: groovy: command not found
./batch.sh: line 6: groovy: command not found
./batch.sh: line 6: groovy: command not found
./batch.sh: line 6: groovy: command not found
./batch.sh: line 6: groovy: command not found
./batch.sh: line 6: groovy: command not found