I am writing a script that iterates through all the files and replaces line feeds at the beginning of each file. For a file like this,
\n \n A line \r\n Another line \r\n \r \f \n \n Few more lines \r\n \r\n
I need to replace all line feeds at the beginning of the file with CRLF, i.e.
\r\n \r\n A line \r\n Another line \r\n \r \f \n \n Few more lines \r\n \r\n
I tried using,
sed -i 's/^[\n]/\r\n/' file.txt
But it doesn't seem to work.
Edit: I am able to replace a range of lines with,
But is there a way to identify if the first character in the file is line feed?