![]() |
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-13 21:41 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS学习入门 & 精彩文章 (教学室) » [Please answer, moderator] How does this command create an empty file? |
| Printable Version 1,722 / 7 |
| Floor1 lucifer | Posted 2003-06-30 00:00 |
| 初级用户 Posts 1 Credits 124 | |
|
set d="echo a.txt > b.txt" & copy %d% > 1.txt & type 1.txt | find /i "echo" > b.txt
And here's another one, same effect as the one above prompt echo$Sb.txt$S$Gc.txt& echo z|cmd|findstr /e "t">b.txt |
|
| Floor2 ko20010214 | Posted 2003-07-04 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
This involves knowledge of setting variables in the DOS environment (the set command), and of pipe/redirection commands (> and |).
The one below involves knowledge of display commands under DOS (the echo command), the prompt command (prompt), the new DOS environment command (cmd, and this is the command command under win2000), and the string-search command (findstr, should be an external command, right?). Please go look up the usage of these commands separately (including some special usages). After you understand them, then come back and think about this complicated composite command. |
|
| Floor3 dv人 | Posted 2003-07-09 00:00 |
| 初级用户 Posts 35 Credits 281 | |
|
findstr ??????????? Shouldn't it be the find command? Format: find "string" /?
|
|
| Floor4 ko20010214 | Posted 2003-07-09 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
The following is quoted from dv's post on 2003-7-9 1:38:48: Maybe. You might be right. I don't know what the OP is talking about either. I'm just guessing. Hehe... |
|
| Floor5 Roy | Posted 2003-07-09 00:00 |
| 管理员 Posts 1,633 Credits 4,869 | |
The following is quoted from dv's post on 2003-7-9 1:38:48:I don't think so......... findstr is a Win2000/XP command........ |
|
| Floor6 dv人 | Posted 2003-07-09 00:00 |
| 初级用户 Posts 35 Credits 281 | |
|
I remembered it wrong,,, there are find and findstr,,, and findstr is still more versatile,,, sorry for making a fool of myself
-----------Searches for strings in files using literal text or regular expressions. Click "Related Topics" in the list for "Devinfo Help" to get a list of the regular expression symbols accepted by findstr. findstr filename ] Parameters /b Matches the pattern if it is at the beginning of a line. /e Matches the pattern if it is at the end of a line. /l Uses a literal search string. /c: string Uses the specified text as a literal search string. /r Uses the search string as a regular expression. This switch is not needed, because unless the /l switch is used, findstr interprets all metacharacters as regular expressions. /s Searches for matching files in the current directory and all subdirectories. /i Specifies that the search is case-insensitive. /x Prints lines that match exactly. /v Prints only lines that do not contain a match. /n Prints the line number before each matching line. /m If the file contains a match, prints only the file name. /o Prints the character offset before each matching line. /g filename Gets search strings from the specified file. /f file Reads the file list from the specified file. /d dirlist Searches the comma-separated directory list. |
|
| Floor7 buddiyar | Posted 2006-07-16 13:38 |
| 初级用户 Posts 75 Credits 160 | |
|
set d="echo a.txt > b.txt"
At this point the contents of b.txt are a.txt & copy %d% > 1.txt copy %d% becomes 1.txt & type 1.txt | find /i "echo" > b.txt Search for the string echo in 1.txt; if found, write it into b.txt if not, it will be empty But note that what is used here is > So no matter how many echo strings there are in 1.txt the contents of b.txt will only be a single echo And here's another one, same effect as the one above prompt echo$Sb.txt$S$Gc.txt& echo z|cmd|findstr /e "t">b.txt |
|
| Floor8 IceCrack | Posted 2006-07-16 19:49 |
| 中级用户 Posts 168 Credits 332 From 天涯 | |
|
set d="echo a.txt>b.txt"
echo %d%>1.txt type 1.txt | find /i "echo">b.txt Why is there such a big difference between having an & and not having one? Doesn't & just serve as a connector? I feel this should have the same effect as the OP's version. But in reality the effect is very different |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |