Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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?
Command Output
PS C:\> Read-NaFile /vol/vol0/etc/rc
#Auto-generated by setup Wed Apr 25 10:11:51 GMT 2012
hostname FILER1
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
routed on
options dns.enable off
options nis.enable off
savecore
PS C:\> Read-NaFile /vol/vol0/etc/rc >c:\test.txt
Notepad Output (one line)
Thanks in advance!
Solved! See The Solution
1 ACCEPTED SOLUTION
migration has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Scott,
Thanks for pointing out. I managed to resolve it.
$lines = gc "path to the file"
$lines | out-file "path to the file" -Encoding unicode
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
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.
- Scott
migration has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Scott,
Thanks for pointing out. I managed to resolve it.
$lines = gc "path to the file"
$lines | out-file "path to the file" -Encoding unicode
