If there is a file with content (not including quotes) " ABCDEFGHH PPP EGFAFDAF", I want to find PPP and delete PPP and all the content after it, and skip if not found! How to do it? Thanks in advance! Posting again with a thick face! :P
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
for /f "tokens=1 delims=PPP" %%i in (1.txt) do (
echo %%i >2.txt
)Originally posted by lxmxn at 2007-5-4 04:27 AM:
Low efficiency.
@echo off
for /f "delims=" %%a in (1.txt) do (
echo %%a|find /i "PPP" >nul 2>&1 && set str=batchering
if not defined str echo\ ...
Originally posted by qasa at 2007-5-3 10:47 PM:
Suppose your file is 1.txt
for /f "tokens=1 delims=PPP" %%i in (1.txt) do (
echo %%i >2.txt
)
Originally posted by chuier at 2007-5-5 21:45:
Can you help me take a look at this paragraph I wrote?
@echo off
setlocal enabledelayedexpansion
set F=1.txt
set "F=%F:"=%"
for %%i in ("%F%") do set F=%%~fi
set a=PPP
set b=
for /f ...
Originally posted by jinrich at 2007-5-6 20:58:
for /f "tokens=1 delims=PPP" %%i in (1.txt) do (
echo\%%i >>2.txt
)
It's relatively simple. However, qasa's echo %%i >2.txt should be changed to echo\%%i >>2.txt
Originally posted by caiyiqun at 2007-5-3 10:31 PM:
If there is a file with content (excluding quotes) " ABCDEFGHH PPP EGFAFDAF", I want to find PPP and delete PPP and all the content that follows it, and skip if not found!
How to do it?
Thanks in advance! Posting again with cheekiness! :P