2014-03-13 01:55 AM
Appreciate if you can help on the scenario below. In powershell window the output is formatted (line by line) but when I send it to a text file, it's only one line. How to keep it the same?
PS C:\> Read-NaFile /vol/vol0/etc/rc
#Auto-generated by setup Wed Apr 25 10:11:51 GMT 2012
ifgrp create multi vif1 -b ip e0a e0b
ifconfig vif1 `hostname`-vif1 mediatype auto netmask 255.255.255.0
route add default 10.50.4.1 1
options dns.enable off
options nis.enable off
PS C:\> Read-NaFile /vol/vol0/etc/rc >c:\test.txt
Notepad Output (one line)
Thanks in advance!
Solved! See The Solution
2 REPLIES 2
Re: output to file only in one line
2014-03-14 07:54 AM
This is an issue with Notepad and how it treats carriage feed / line return. This particular issue is why you shouldn't use Notepad to edit config files, Notepad does not respect the conventions of the source format and changes the output. If you edit /etc/exports with Notepad, then save, go to a Unix system and run cat -v /etc/exports you will see the "^M" character all through the file, you should see "$". I have seen this break config files many times. Unfortunately this is common with a lot of Microsoft products.
If you use something like Wordpad(on Windows 7 at least), Notepad++, Textpad, Crimson Editor, etc they will show you the ouput in the correct format without issue. You would have to build a wrapper script to change the Unix CR/LF to the Windows ^M to get Notepad to show the output correctly.