开发者

How to create and run a bash file?

开发者 https://www.devze.com 2023-04-03 18:15 出处:网络
How to create a bash file? I found following bash script. #!/b开发者_如何学运维in/bash for f in *.wav; do

How to create a bash file?

I found following bash script.

#!/b开发者_如何学运维in/bash
for f in *.wav; do
  echo "Processing $f file..."
  afconvert -f caff -d LEI16@44100 -c 1 "$f" "${f/wav/caf}"
done

I have Mac and Windows.

But I don't know where I have to put this and how I can run this script?


Just save the text into a file called my_bash_script a file, make it executable and run it from the command line like this:

chmod u+x my_bash_script
./my_bash_script

Judging by the file it will need to be in a directory containing *.wav files.


As you have two different OS setup, I will split my answer in two parts.

First: Windows

Windows does not have a Bash interpreter, nor the afconvert program the code above is trying tu run. Your best bet will be to use Cygwin to install a Unix console on your Windows. Also I don't know, where you could get afconvert from.

OSX

OSX does have a console and the afconvert software (at least my OSX does). You can simply drop the file in a folder and give it a name ending in .sh. Then you should be able to run it.


Just paste the text into a plaint text file and then mark it as executable:

chmod +x yourScript

To run it:

./yourScript


Place the script anywhere you have your .wav files. When fallow instructions given here: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_01.html#sect_02_01_03

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号