简体   繁体   English

如何编写将在Windows和Linux上运行的bash脚本

[英]How to write a bash script that will run on Windows and Linux

I'm writing a bash script to be executed on both Windows and Linux machines from the terminal. 我正在编写一个bash脚本,可以从终端在Windows和Linux计算机上执行该脚本。 One of the lines calls Rscript, a program for executing .R programs. 其中一行称为Rscript,这是一个用于执行.R程序的程序。 The issue is that in Linux, the command is simply Rscipt , whereas in Windows, it is Rscript.exe . 问题在于,在Linux中,命令只是Rscipt ,而在Windows中,则是Rscript.exe Is there any way to modify the program such that it'll run seamlessly on both Windows and Linux operating systems? 有什么方法可以修改程序,使其可以在Windows和Linux操作系统上无缝运行?

Thank you. 谢谢。

You can name any Unix executable with suffix .exe, no problem too... the first bits in Linux are magic bits which indicates the real type of one file. 您可以使用后缀.exe命名任何Unix可执行文件,也没有问题... Linux中的第一位是魔术位,它指示一个文件的真实类型。

or 要么

Simply use perl or python scripts, Perl and python can work both on Windows and Linux. 只需使用perl或python脚本,Perl和python就可以在Windows和Linux上运行。

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

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