我怎样写一个bash脚本,下载并解压缩文件在Mac上? [英] How do I write a BASH script to download and unzip file on a Mac?
本文介绍了我怎样写一个bash脚本,下载并解压缩文件在Mac上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要创建一个bash脚本,将在Mac上运行。它需要下载一个ZIP文件了一个网站,并把它解压到特定的位置。
I need to create a bash script that will work on a mac. It needs to download a ZIP file off a site and unzip it to a specific location.
- 下载ZIP文件(
卷曲-O
) - 将文件解压缩到一个特定的位置(
解压filename.zip路径/要/保存
) - 删除.zip文件
我需要让这样的人可以双击桌面上的文本文件,它会在终端自动运行。
I need to make it so people can double click the text file on their desktop and it will automatically run in terminal.
我如何让这个用户可以双击桌面上的图标,它将运行?请问需要的文件扩展名是什么?
How do I make it so that the user can double click the icon on the desktop and it will run? What extension does the file need?
推荐答案
OSX使用相同的GNU SH / bash作为Linux的
OSX uses the same GNU sh/bash as Linux
#!/bin/sh
mkdir /tmp/some_tmp_dir && \
cd /tmp/some_tmp_dir && \
curl -sS http://foo.bar/filename.zip > file.zip && \
unzip file.zip && \
rm file.zip
第一行#!/ bin / sh的
就是所谓的家当行,是强制性
the first line #!/bin/sh
is so called "shebang" line and is mandatory
这篇关于我怎样写一个bash脚本,下载并解压缩文件在Mac上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文