![]() |
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-08-09 04:56 |
47,811 topics / 349,895 posts / today 0 new / 48,253 members |
| DOS批处理 & 脚本技术(批处理室) » Use sed to delete blank lines made up of spaces |
| Printable Version 1,889 / 18 |
| Floor1 amio | Posted 2008-07-13 12:30 |
| 中级用户 Posts 93 Credits 206 | |
|
Use sed to delete blank lines made up of spaces
|
|
| Floor2 26933062 | Posted 2008-07-13 12:37 |
| 银牌会员 Posts 879 Credits 2,268 | |
| Floor3 amio | Posted 2008-07-13 12:52 |
| 中级用户 Posts 93 Credits 206 | |
|
Seems like it doesn't do anything
|
|
| Floor4 26933062 | Posted 2008-07-13 13:13 |
| 银牌会员 Posts 879 Credits 2,268 | |
Originally posted by amio at 2008-7-13 12:52: What do you mean by “seems like”? Did you test it? Why does it test fine for me。。。 |
|
| Floor5 amio | Posted 2008-07-13 13:18 |
| 中级用户 Posts 93 Credits 206 | |
|
sed -i "/^ *$/d" a.txt|find /v ""
This is how I tested it |
|
| Floor6 26933062 | Posted 2008-07-13 14:01 |
| 银牌会员 Posts 879 Credits 2,268 | |
|
If you wanted to modify the source file directly, then you should have made that clear in the first post.。
Nope. |
|
| Floor7 HAT | Posted 2008-07-13 14:38 |
| 版主 Posts 5,017 Credits 9,023 | |
| Floor8 amio | Posted 2008-07-13 16:31 |
| 中级用户 Posts 93 Credits 206 | |
Originally posted by HAT at 2008-7-13 02:38 PM: Did you test whether this works? Why doesn't mine work then? |
|
| Floor9 26933062 | Posted 2008-07-13 16:44 |
| 银牌会员 Posts 879 Credits 2,268 | |
|
The OP is really something, just one sentence saying it doesn't work.
What exactly is the problem, and where doesn't it work? Are you really that stingy? Can't even bear to describe what happens when it doesn't work? People are trying to help you, don't act like they're the ones begging you。。。 |
|
| Floor10 HAT | Posted 2008-07-13 17:04 |
| 版主 Posts 5,017 Credits 9,023 | |
|
I tested it, and it works.
Maybe your sed version is too old. C:\Test>C:\ProgramMy\GnuWin32\sed --version |
|
| Floor11 amio | Posted 2008-07-13 17:21 |
| 中级用户 Posts 93 Credits 206 | |
|
Sorry, I got it wrong. What I meant was deleting the spaces at the beginning of a line. Delete only the leading spaces, but keep the text after them.
For example: aaaaaaaaaaa becomes aaaaaaaaaaa |
|
| Floor12 HAT | Posted 2008-07-13 17:29 |
| 版主 Posts 5,017 Credits 9,023 | |
|
Next time when asking a question, it's best to give an example right in the first post, hehe. |
|
| Floor13 26933062 | Posted 2008-07-13 17:35 |
| 银牌会员 Posts 879 Credits 2,268 | |
|
Could it really be a sed version issue? Doesn't HAT's sed need find for filtering?
: |
|
| Floor14 amio | Posted 2008-07-13 17:38 |
| 中级用户 Posts 93 Credits 206 | |
|
This was given on the CU forum. Does it mean the same thing?
sed 's/^[[:blank:]]\+//' |
|
| Floor15 HAT | Posted 2008-07-13 18:56 |
| 版主 Posts 5,017 Credits 9,023 | |
|
If you've lurked on CU long enough, then you'd know that [[:blank:]] includes not only spaces, but all blank characters, hehe.
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |