![]() StringReplace, varOUT, varOUT, YYY, DEF, All StringReplace, varOUT, varOrigin, xxx, ABC, All (Get-Content c:\temp\test.txt).replace('', 'MyValue') | Set-Content c:\temp\test.txt You could use PowerShell (new WindowsTM batch tool) you can also use the search&replace dialog box and enable Batch-Replace: you can record a search&replace in a macro, edit that macro by copying the command line, and run this. You may be able to find a newer version of sed for Windows than this but for command line tools it is possible they have not changed all that much since 2010 anyway.Īlready good answers, here are some more. ![]() That would save you having to edit the one-liner, which somewhat defeats the purpose of finding a "canned" solution to the problem. Note that with sed one-liners for Linux the file separator is a forward slash('/') instead of a backslash('\') and for that reason it is a good idea to look for a one-liner page for the Windows version of sed. You can find sed for Windows as freeware if you are using Windows. You feed a file(which can also be standard input such as via a pipe on the command line) into it and it processes the text using the command and outputs the result. But briefly sed is a "stream editor." It is used on the command line. There is a good chance what you want to do is already possible using one of them. There are many " one-liners" you can find on the web. I am sure it supports regular expressions.Īlso for regex substitutions on each line of text processing entire files see the Linux "sed" tool. I keep saying I will get back into using it myself. ![]() With vi(on which vim is based) it was done with one command. Something like that in a lengthy file can quickly tire you out if you physically do the cut and paste operations manually. But I can remember doing things like cutting all but the first sentence in each paragraph in a file and pasting it at the bottom of the file. It is free and is capable of operations difficult in most free text editors. For repetitive commands you may wish to take a look at vim
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |