You are not logged in.
Basically, I need a way to capture the results of a find command to a variable in a bash script so I can recall the filename in a more complex string of commands. How is this best accomplished?
For example:
$ find /home/user -name '*.wav'
That outputs a list of say 15 .wav files. I need to feed each filename into a longer string that does several things to the wav files. If it were just one wav file, I think I could capture it like this:
var=`find /home/user -name '*.wav'`
Then I can simply use ${var} in the longer string of commands. I dunno how to do it with multiple files in this way.
Last edited by graysky (2010-02-20 20:18:38)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
all='find /home/user -name '*.wav'
for var in $all
do
echo $var
done
Offline
Apologies, misread.
Last edited by Michael C. (2010-02-20 20:38:31)
Offline
Yeah, I need to separate each of the wav files as their own variable, run them through a string of commands, then repeat for the 2nd on the the list.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Oh, I guess I didn't misread.
for foo in $(find /home/user '*.wav')
do
bar=$(do_something "$foo")
bigger_var="$bigger_var $bar"
done
Last edited by Michael C. (2010-02-20 20:41:50)
Offline
Thank you! This did just what I wanted it to do
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline