Monday, January 31, 2022

[SOLVED] How to do a "sed -" like operation on Windows?

Issue

I have a large 55 GB file in which there is a sentence on every line. I want to check if there are any lines that have a dot "." at the end, and then if there is, I want to insert a space before the dot in that line.

Ex: I like that car. Replace with: I like that car .

A space before the trailing dot on every line if there is a dot.

I don't have any cygwin or unix and I use a windows OS. Is there a sed like common that I can do on this 55GB! file?

I tried GetGNUWin32 but I am unable to determine the actual command there.


Solution

Install Perl. Strawberry Perl is probably the best distribution for Windows. http://strawberryperl.com/

To do what you're talking about in Perl, it would be this:

perl -p -i -e's/\.$/ ./' filename


Answered By - Andy Lester
Answer Checked By - Terry (WPSolving Volunteer)