unreadable output file in powershell

If you redirect a not-completly-string output (like a spfile) to a file in powershell, you may not see the same in the file as in the output

  • without redirection
    
    PS C:\> Select-String "compatible" .\spfileDB01.ora
    spfileDB01.ora:13:*.compatible='11.2.0.4.0'
    
  • with redirection
    
    PS> Select-String "compatible" .\spfileDB01.ora > compatible.txt
    PS> vim -b .\compatible.txt
    ÿþ^M^@
    ^@s^@p^@f^@i^@l^@e^@D^@B^@0^@0^@1^@.^@o^@r^@a^@:^@1^@3^@:^@*^@.^@c^@o^@m^@p^@a^@t^@i^@b^@l^@e^@=^@'^@1^@1^@.^@2^@.^@0^@.^@4^@.^@0^@'^@^M^@
    ^@
    
  • With redirection and conversion to ascii
    
    PS> Select-String "compatible" .\spfileDB01.ora | 
      Out-File -Encoding ASCII .\compatible.txt
    
    PS> vim .\compatible.txt
    
    spfileDB01.ora:13:*.compatible='11.2.0.4.0'
    

With Out-File (instead of >), you can specify the encoding, which does the trick

One thought on “unreadable output file in powershell”

  1. Make sure you remember this to always get that good flyer text kung
    fu. In China’s history, the Tang Dynasty was a period
    when the polity and economy were highly developed and the culture and art were thriving.
    Many times we do not have time to catch our own bait fish
    for our fishing trips so we go to our loc.

Leave a Reply

Your email address will not be published.


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>