秀才刘哥 發表於 2022-7-16 11:33:48

苹果mac批处理命令怎么使用? mac系统执行bat批处理的技巧

<p>mac系统如何执行批处理?我们使用windows时经常会用到批处理文件。双击下.bat文件。大量的工作就会替你完成。这功能够酸爽。mac下是否有同样的功能那?答案是肯定的。下面我们就来看看详细的教程。</p>
<h3>mac系统如何执行批处理。</h3>
<p>新建一个文本文件。命名为test.command。注意一定要以command为结尾。</p>
<p style="text-align: center"><img alt="" src="https://img.jbzj.com/file_images/article/202207/2022071611242482.jpg" /></p>
<p>打开『<strong>终端</strong>』程序。给test.command加上可执行权限。命令为<span style="color: #ff0000"><strong>chmod +x test.command.</strong></span></p>
<p style="text-align: center"><img alt="" src="https://img.jbzj.com/file_images/article/202207/2022071611242483.jpg" /></p>
<p>用编辑器打开文本文件。输入可以在终端执行的指令。<strong>例如ls</strong></p>
<p style="text-align: center"><img alt="" src="https://img.jbzj.com/file_images/article/202207/2022071611242484.jpg" /></p>
<p>将文件保存到桌面上。然后双击打开。效果如图所示:</p>
<p style="text-align: center"><img alt="" src="https://img.jbzj.com/file_images/article/202207/2022071611242585.jpg" /></p>
<p>根据自己的需求。编写你自己的批处理文件把。这里有一个问题。就是批处理执行完了。弹出的那个命令行不会自动关闭。为了解决这个问题。在批处理文件的最后加上代码:</p>
<p>&nbsp;</p>
<div class="jb51code">
<pre class="brush:plain;">
osascript -e 'tell application&quot;Terminal&quot; to close (every window whose name contains&quot;.command&quot;)' &amp;
exit</pre>
</div>
<p style="text-align: center"><img alt="" src="https://img.jbzj.com/file_images/article/202207/2022071611242586.jpg" /></p>
<p>现在就和windows的bat文件体验完全相同。值得提醒的是在mac系统下你还可以编写shell脚本。<strong>shell脚本的语法在网上就可以找到</strong>。相信您可以做出非常使用的批处理文件。</p>
<p><span style="color: #ff0000"><strong>注意事项:</strong></span></p>
<p>一定记得给文件可执行权限。否则脚本服务执行mac系统中的删除功能谨慎使用。因为恢复起来比较难</p>
<p>以上就是mac系统执行bat批处理的技巧,希望大家喜欢,请继续关注琼殿技术社区。</p>
<p><strong>相关推荐: </strong></p>
<p><a target="_blank" href="https://www.jb51.net/os/MAC/838034.html">苹果系统capslock键不能切换大小写怎么办? mac无法大写锁定的解决办法 </a></p>
<p><a target="_blank" href="https://www.jb51.net/os/MAC/800802.html">mac系统的电脑怎么切换城市天气? mac切换其他城市的天气的技巧 </a></p>
<p><a target="_blank" href="https://www.jb51.net/os/MAC/810644.html">Mac os怎么一键显示桌面? mac显示桌面快捷键设置方法 </a></p>
頁: [1]
查看完整版本: 苹果mac批处理命令怎么使用? mac系统执行bat批处理的技巧