China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-13 20:54
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » [Please answer, moderator] How does this command create an empty file? View 1,721 Replies 7
Original Poster Posted 2003-06-30 00:00 ·  中国 山东 济南 联通
初级用户
Credits 124
Posts 1
Joined 2003-06-14 00:00
23-year member
UID 5116
Gender Male
Status Offline
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











Floor 2 Posted 2003-07-04 00:00 ·  中国 江西 吉安 电信
版主
★★★★
Credits 7,296
Posts 1,628
Joined 2002-10-16 12:00
23-year member
UID 10
Gender Male
Status Offline
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.
ko20010214
=================================
大功告成,打个Kiss!
ko20010214@MSN.com
神州优雅Q300C
Intel CeleronM 370处理器 | 256MbDDR内存
40G硬盘 | USB2.0 | IEEE 1394
13.3 ' WXGA 宽屏(16:10) | COMBO光驱
10/100M网卡 | 四合一读卡器
Floor 3 Posted 2003-07-09 00:00 ·  中国 天津 联通
初级用户
你说呢
Credits 281
Posts 35
Joined 2003-06-23 00:00
23-year member
UID 5734
Gender Male
Status Offline
findstr ??????????? Shouldn't it be the find command? Format: find "string" /?
dv人-----------------------------呀
Floor 4 Posted 2003-07-09 00:00 ·  中国 江西 吉安 电信
版主
★★★★
Credits 7,296
Posts 1,628
Joined 2002-10-16 12:00
23-year member
UID 10
Gender Male
Status Offline
The following is quoted from dv's post on 2003-7-9 1:38:48:
findstr ??????????? Shouldn't it be the find command? Format: find "string" /?

Maybe. You might be right. I don't know what the OP is talking about either. I'm just guessing. Hehe...
ko20010214
=================================
大功告成,打个Kiss!
ko20010214@MSN.com
神州优雅Q300C
Intel CeleronM 370处理器 | 256MbDDR内存
40G硬盘 | USB2.0 | IEEE 1394
13.3 ' WXGA 宽屏(16:10) | COMBO光驱
10/100M网卡 | 四合一读卡器
Floor 5 Posted 2003-07-09 00:00 ·  中国 香港
管理员
★★★★
專業島民
Credits 4,869
Posts 1,633
Joined 2002-12-10 00:00
23-year member
UID 465
Gender Male
Status Offline
The following is quoted from dv's post on 2003-7-9 1:38:48:
findstr ??????????? Shouldn't it be the find command? Format: find "string" /?
I don't think so......... findstr is a Win2000/XP command........
我的網站:http://mw16.2ya.com/ 我的網誌: http://scrappedblog.blogspot.com/
~
我的Winamp正在播放的歌曲:
Floor 6 Posted 2003-07-09 00:00 ·  中国 天津 联通
初级用户
你说呢
Credits 281
Posts 35
Joined 2003-06-23 00:00
23-year member
UID 5734
Gender Male
Status Offline
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.
dv人-----------------------------呀
Floor 7 Posted 2006-07-16 13:38 ·  中国 江苏 苏州 电信
初级用户
★★
Credits 160
Posts 75
Joined 2006-06-28 01:07
20-year member
UID 57661
Gender Male
Status Offline
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
Floor 8 Posted 2006-07-16 19:49 ·  中国 辽宁 大连 教育网
中级用户
★★
DOS之友
Credits 332
Posts 168
Joined 2005-10-06 00:00
20-year member
UID 43171
Gender Male
From 天涯
Status Offline
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
Forum Jump: