Solved

Powershell unix equivilent of vi -b

Posted on 2011-09-10
4
1,043 Views
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.
0
Comment
Question by:rwskas
4 Comments
 
LVL 13

Expert Comment

by:khairil
ID: 36517757
0
 
LVL 4

Expert Comment

by:krf1963
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.
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 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

0
 
LVL 6

Author Closing Comment

by:rwskas
ID: 36525011
That worked, THanks
0

Featured Post

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Quest Powershell code 7 28
Powershell script include embedded images 10 47
[switch] $NoInheritance - Powershell Code 5 20
Remote Powershell Issue 3 32
Synchronize a new Active Directory domain with an existing Office 365 tenant
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
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…

749 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