Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hey all, I can usually handle any issues I have using the Search (really great, btw), but I couldn't find anything on this particular question:
How do you delete blank lines in a .txt file?
Here's an example:
abs123
g53ytv53y
35v4w6u6i
6u
6un56i76uen6u
I want the above to read:
abs123
g53ytv53y
35v
4w6u6i
6u
6un56i7
6uen6u?

If you are doing a small number of files use a text processor and replace the successive newline characters with a single newline character. If you are doing many write a small utility program.

Use the following simple (just one line!) batch to remove blank lines from a txt file
@Echo Off
For /F "tokens=* delims=" %%A in (%1) Do Echo %%A >> %2
where %1 is the source file and %2 the result, i.e.
Clean Mytext.txt MyText.new
assumed you named the batch Clean.bat.
That works under Win NT/XP/2K only.

i thought the forum security guy and the admin decided all these batch file posts should be in the DOS section...
GIMPS

gimmpy255:
I think the only thing decided was that only questions on batch files that work in 'real' standalone DOS could be posted in the DOS area. There is still some question of what is considered a 'program'.

I have asimilar question and I am not sure how to modify your answer to fit my needs, could you point me in the right direction.
here it is:
I have a text file with the following info:
lm_loweralpha-numeric#1-oxid#299.rt:
15999984 bytes read, disk access time:0.61 s
verifying the file...
searching for 1 hash...
cryptanalysis time: 0.00 sstatistics
----------------
plaintext found: 0 of 4 (0.00%)
total disk access time: 30.23 s
total cryptanalysis time: 0.76 s
total chain walk step: 771903
total false alarm: 455
total chain walk false alarm: 184850result
----------------
af6e956c6 <notfound> hex:<notfound>
af6e956c6 <notfound> hex:<notfound>
af6e956c6 <notfound> hex:<notfound>
f367ef4ff <notfound> hex:<notfound>
f367ef4ff <notfound> hex:<notfound>
e165f0192 <notfound> hex:<notfound>
the file is named cracked.txtfrom a batch file, I would like to delete all of the lines of text up to and including the
result
----------------so that when the batch file is complete, all that will be left in the file is:
af6e956c6 <notfound> hex:<notfound>
af6e956c6 <notfound> hex:<notfound>
af6e956c6 <notfound> hex:<notfound>
f367ef4ff <notfound> hex:<notfound>
f367ef4ff <notfound> hex:<notfound>
e165f0192 <notfound> hex:<notfound>
Since I will never be certain how many lines will proceed the hashes, what command should I use to edit the text file from a batch file.Thank you,
Ramius

Hi Ranius,
Try this. Your output winds up in CRACKED.NEW
::=========== cracked stripper ====
@echo off > cracked.new
set keep=NOfor /f %%L in (cracked.txt) do call :keeper %%L
goto :eof:keeper
if %keep%==YES echo %1 >> cracked.new
echo %1|find "result" > nul
if not errorlevel 1 set keep=YES
::======M2
If at first you don't succeed, you're about average.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |