Saved Bookmarks
| 1. |
Solve : stream editing in cmd shell? |
|
Answer» HI - I have a file with some string tags in it like this: ... FOO/path1 FOO/path2 FOO/path3 ... I want to replace FOO in the above file with values of my choosing (shell/environment variable values). I've tried lots of clunky things with msdos and so far have no luck. I would much prefer to use ant or even some more functional shell (KORN or bash), but need to stick for now with the standard cmd (Win2K/XP) shell. I cannot add utilities - this has to be with the standard/default install utilities in cmd shell. Is there any way to do this? Thanks in advance for your assistance. dan The cmd shell does not have a built in SEARCH and replace function. You can try something like this: Example: CODE: [Select]for /f "tokens=2 delims=/" %%a in (test.txt) do echo NEW/%%a >> out.dat The above code is to be used in a batch file. From the command line use: Code: [Select]for /f "tokens=2 delims=/" %a in (test.txt) do echo NEW/%a >> out.dat You can change the NEW/ string to any SET of characters you like. Some Windows Scripting languages can do this within the same file. The cmd shell cannot, therefore the output file. Hope this helps. 8-) |
|