I am using Linux machine for development and then deploying my script files to Azure function app which is a Windows machine.
Then I am copying shell script files to wasb from Azure function app.
I am getting following error when running shell script in Edge node on Azure HDI cluster
$'\r': command not found
My script files are not executed properly.
What is the best way to convert dos2unix option in C# Azure function?
You could upload your file to Linux and change file format.
dos2unix <filename>
Another easy solution is that if you install Notepad++, it supports automatic conversion format to Unix(LF).

You don't have to do anything special to read a file that contains Unix-style newlines (\n) instead of \r\n. .NET IO methods treat both as newlines.
You could write
var lines-File.ReadAllLines("myUnixText.txt");
or
using(var reader=File.OpenText("myUnixText.txt"))
{
string line;
while( (line=reader.ReadLine()) !=null)
{
// Do something
}
}
to read lines whether the line ending is \r or \n
To prove it :
var numbers = new[]{1,2,3,4,5,6};
var lines=String.Join("\n",numbers);
File.WriteAllText("myUnixText.txt",lines);
var newLines=File.ReadAllLines("myUnixText.txt");
Debug.Assert(newLines.Length==6);
Even though only a single string was written, File.ReadAllLines read 6 lines from the file
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