0

I have a text file File.txt and the content is below

Application_Servers\Base\Baseinstall\BGInfo
Application_Servers\Base\Baseinstall\CLRRSServerManager
Application_Servers\Base\Baseinstall\PCSUtils
Application_Servers\Base\Baseinstall\PostOSLoad
Application_Servers\Base\Baseinstall\Registration
Application_Servers\Base\Baseinstall\WMI
Application_Servers\Base\Baseinstall\x64\RSAutoExNt\v1.2
Application_Servers\Base\w2k16update\EveryTime
RS Batch\RSQueueClientLib\V_1_0
RS Batch\RSQueueClientLib\V_2_2
Utilities\Clrstuff\clrrs\Bin

I want to replace \ with /, how can I achieve this? Please give me shell command

2
  • What have you tried yourself and what didn't work? Commented Mar 16, 2020 at 20:34
  • It depends on which way you are going. If you have what you show and want replace '\' with '/' and you are on a Unix/Linux box, you want tr '\\' '/' (e..g tr '\\' '/' < file > newfile).. If you are not on a Unix/Linux box, then why have the POSIX shell tags [shell] and [sh] which have no application to windows (other than in WSL). Commented Mar 16, 2020 at 21:04

1 Answer 1

1

gc = get-content sc = set-content

get-content....

The Get-Content cmdlet gets the content of the item at the location specified by the path, such as the text in a file or the content of a function. For files, the content is read one line at a time and returns a collection of objects, each of which represents a line of content. https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-content?view=powershell-7

set-content....

Set-Content is a string-processing cmdlet that writes new content or replaces the content in a file. Set-Content replaces the existing content and differs from the Add-Content cmdlet that appends content to a file. To send content to Set-Content you can use the Value parameter on the command line or send content through the pipeline. https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-content?view=powershell-7

-replace() .....

Replace characters within a string

The Code.... (gc "C:\folder\File.txt") -replace '\\','/' | sc "C:\folder\File.txt"

Please do not ask any further questions on stackoverflow, if you have not tried coding the scripts yourself first and get stuck. We are here for when you get stuck. As it stands you haven't even started or made an attempt.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.