简体   繁体   English

使用Shell脚本(Mac)创建Shell脚本

[英]create a shell script with a shell script (mac)

I've been creating mac shell executables with this method: 我一直在使用这种方法创建mac shell可执行文件:

  • Create a file; 创建一个文件;
  • Add #!/bin/sh ; 添加#!/bin/sh ;
  • Add the script; 添加脚本;
  • Run chmod 755 nameofscript . 运行chmod 755 nameofscript

I now need to create a shell script to create a shell script in another directory and make it executable (with chmod) so that it can be run on startup. 现在,我需要创建一个Shell脚本,以便在另一个目录中创建一个Shell脚本,并使它可执行(使用chmod),以便可以在启动时运行它。

#!/bin/sh

dir=/tmp
fnam=someshellscript

echo '#!/bin/sh' > $dir/$fnam
echo 'find /bin -name "*X*"' >> $dir/$fnam
chmod 755  $dir/$fnam
#!/bin/sh
echo "script goes here!" > /path/to/place
chmod 755 /path/to/place

?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM