for example to define a script that print "hello".
I can do the following with nodejs (hello_node)
#!/bin/node
console.log(`hello ${process.argv[2]}`)
Then I will call it
./hello_node "world"
Also in Python
#!/bin/python3.7
print("hello world")
The same works in PHP and ruby, is there a way to do this in C# ?
I've tried the below, but it didn't work
#!/usr/local/share/dotnet/dotnet run
using System;
public static class Program {
public static void Main(string[] args)
{
Console.WriteLine("Hello " + args[1]);
}
}
A shebang (#!) tells the it to open the file with a specific command.
The dotnet run command can only be used to run projects, not single files.
You could try using the dotnet-script tool, but you'd need to setup the directory which might be a big downside based on what you're trying to achieve
https://github.com/filipw/dotnet-script
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With