You are not logged in.
I am trying to figure out why I can't get a variable ($switches in the script below) to output correctly in my bash script but am at a loss to do so. Calling the variable within the for loop results in a null value for it even though I have defined it. The variable just needs to replace the -V 2 text in the commented line right above it. It simply does not work.
How can I force my encode routine to read the vars in without redefining them within it?
#!/bin/bash
cores=4
switches="-V 2"
encode() {
for file; do
fileout=$(echo "$file" | sed s'/.wav//')
#lame -V 2 "$file" "$fileout".mp3; done
lame "$switches" "$file" "$fileout".mp3; done
}
export -f encode
find . -name '*.wav' -print0 | xargs -0 -n 1 -P $cores bash -c 'encode "$@"' --
Last edited by graysky (2010-03-03 23:29:33)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Online
your encode part is running in a subshell, try export switches="-V 2"
Offline
OK! I got it now, thanks! The variables are defined in /etc/multilame.conf
#!/bin/bash
. /etc/multilame.conf
encode() {
. /etc/multilame.conf
for file; do
fileout=$(echo "$file" | sed s'/.wav//')
lame "$switches" "$file" "$fileout".mp3; done
}
export -f encode
find . -name '*.wav' -print0 | xargs -0 -n 1 -P $cores bash -c 'encode "$@"' --
Last edited by graysky (2010-03-03 23:29:15)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Online