![]() |
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-06 09:25 |
48,039 topics / 350,124 posts / today 0 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » [Help] How to query and output a section of data between 2 dates |
| Printable Version 1,591 / 20 |
| Floor1 li104268 | Posted 2007-10-30 18:54 |
| 初级用户 Posts 13 Credits 30 | |
|
As the title says
Please help me write it Thanks!!! |
|
| Floor2 li104268 | Posted 2007-10-30 18:55 |
| 初级用户 Posts 13 Credits 30 | |
|
For example, between October 1, 2007 and November 1, 2007
|
|
| Floor3 abcd | Posted 2007-10-30 19:57 |
| 银牌会员 Posts 739 Credits 1,436 | |
|
Post a piece of text as an example first
|
|
| Floor4 li104268 | Posted 2007-10-30 20:54 |
| 初级用户 Posts 13 Credits 30 | |
|
Serial number Order User Production date Repair date Completion date
de23422 13321 Wang Xuebing June 18, 2006 March 28, 2007 April 10, 2007 fa22578 18032 Li Xue August 5, 2006 April 20, 2007 April 29, 2007 。。。。。 。。。。。 。。。。。 ke23089 52108 Zhao Guanghui January 5, 2007 le58212 32102 Zhang Yaofeng January 5, 2007 October 20, 2007 October 28, 2007 The format is like this, query the records between October 20, 2007 and April 20, 2007 |
|
| Floor5 abcd | Posted 2007-10-30 21:35 |
| 银牌会员 Posts 739 Credits 1,436 | |
|
So it's judged by the "Repair date"
|
|
| Floor6 li104268 | Posted 2007-10-30 21:48 |
| 初级用户 Posts 13 Credits 30 | |
|
Yes, it's just that I can't figure out how to write this expression, hope everyone can give me some advice!!!
|
|
| Floor7 26933062 | Posted 2007-10-30 23:53 |
| 银牌会员 Posts 879 Credits 2,268 | |
|
[ Last edited by 26933062 on 2007-10-30 at 11:55 PM |
|
| Floor8 junchen2 | Posted 2007-10-31 00:55 |
| 高级用户 Posts 219 Credits 537 From 杭州--半山 | |
|
echo off
@for /f "tokens=1-6 delims=: " %%a in ('findstr /n " 2007年4月20日 " 111.txt') do ( if "%%f" == "2007年4月20日" set n=%%a& goto 2 ) :2 @for /f "tokens=1-6 delims=: " %%a in ('findstr /n " 2007年10月20 " 111.txt') do ( if "%%f" == "2007年10月20" set n1=%%a& goto 3 ) :3 sed -n "%n%,%n1%p" 111.txt|more>>fix_date.txt pause [ Last edited by junchen2 on 2007-10-31 at 01:07 AM |
|
| Floor9 junchen2 | Posted 2007-10-31 01:25 |
| 高级用户 Posts 219 Credits 537 From 杭州--半山 | |
|
Not sure whether this can be written using only SED
[ Last edited by junchen2 on 2007-10-31 at 01:39 AM |
|
| Floor10 lxmxn | Posted 2007-10-31 04:52 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Try this:
sed "/^\(]\+]\+\)\{4\}2007年4月20.*/,/^\(]\+]\+\)\{4\}2007年10月20.*/!d" UrTestFile.txt|sed "1d;$d" [ Last edited by lxmxn on 2007-10-31 at 04:55 AM |
|
| Floor11 junchen2 | Posted 2007-10-31 08:50 |
| 高级用户 Posts 219 Credits 537 From 杭州--半山 | |
|
I tried brother lxmxn's code, and it works well. Thanks!
[ Last edited by junchen2 on 2007-10-31 at 08:52 AM |
|
| Floor12 li104268 | Posted 2007-10-31 10:02 |
| 初级用户 Posts 13 Credits 30 | |
|
Many thanks, everyone :D
It's just that I can't understand the moderator's one :( |
|
| Floor13 li104268 | Posted 2007-10-31 10:32 |
| 初级用户 Posts 13 Credits 30 | |
Originally posted by 26933062 at 2007-10-30 11:53 PM: |
|
| Floor14 abcd | Posted 2007-10-31 11:10 |
| 银牌会员 Posts 739 Credits 1,436 | |
|
What post #7 wrote has a problem
For example: |
|
| Floor15 li104268 | Posted 2007-10-31 11:36 |
| 初级用户 Posts 13 Credits 30 | |
Originally posted by junchen2 at 2007-10-31 12:55 AM: sed /? says it is not an internal or external command... What command is this? This batch file gives no result on my machine :( |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |