Powershell unix equivilent of vi -b

Posted on 2011-09-10
Medium Priority
Last Modified: 2012-05-12
Does anyone know the Powershell equivilent to the unix command 'vi -b'? I would like to be able read the line end characters of a file.
Question by:rwskas
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 13

Expert Comment

ID: 36517757

Expert Comment

ID: 36521980
If you use the command:

get-content -encoding byte c:\file.txt

Powershell returns an array of bytes which is the content of the file. You can then examine the whole file a byte at a time.
LVL 70

Accepted Solution

Qlemo earned 2000 total points
ID: 36524549
To display e.g. ^M^J at the end of Windows text file lines, you can use:
(get-content c:\file.txt -Delimiter "§").Replace([string][char]13, "^M"+[char]13).Replace([string][char]10, '^J'+[char]10)

Open in new window


Author Closing Comment

ID: 36525011
That worked, THanks

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief introduction to what I consider to be the best editor for PowerShell.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question