![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-11-11 12:34 |
47,815 topics / 349,930 posts / today 0 new / 48,291 members |
| DOS批处理 & 脚本技术(批处理室) » How to delete empty lines without using sed |
| Printable Version 2,767 / 18 |
| Floor16 knoppix7 | Posted 2007-08-30 17:33 |
| 银牌会员 Posts 634 Credits 1,287 From cmd.exe | |
|
...........No consideration was given to this matter...It's over...........
@echo off set runtimes=0 FOR /F "delims=" %%i in (myfile.txt) do ( call :func1 "%%i" "%%i" ) pause pause pause :func1 set /a runtimes=%runtimes%+1 set EL=1 set T1=%1 set T1=%T1: =% if NOT %T1%=="" set EL=0 if %EL%==0 ( if NOT %runtimes%==1 echo+>>done.txt set /p "null=%2"<nul>>done.txt ) goto :EOF |
|
| Floor17 kennyfan | Posted 2007-08-30 18:45 |
| 中级用户 Posts 112 Credits 259 | |
|
Hehe..Indeed interesting..Creative..Learned!~
|
|
| Floor18 wert123 | Posted 2007-08-30 18:59 |
| 中级用户 Posts 135 Credits 301 | |
Originally posted by knoppix7 at 2007-8-30 05:33 PM: The spaces in front of non-empty lines are also removed. |
|
| Floor19 ngd | Posted 2007-12-21 12:48 |
| 中级用户 Posts 108 Credits 312 | |
|
It can be used like this. Note that there is a space before *, sed "/^ *$/d"
# Delete all blank lines in the file sed '/^$/d' # Method 1 sed '/./!d' # Method 2 |
|
| Prev 1 2 |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |