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-07 07:23
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » How to obtain the value returned after a command is executed View 3,372 Replies 38
Floor 31 Posted 2008-01-05 23:32 ·  中国 四川 成都 电信
初级用户
Credits 100
Posts 45
Joined 2007-12-11 18:02
18-year member
UID 105341
Gender Male
Status Offline
@echo off
for /f %%b in (a.txt) do set c=%%b
set /a c+=1
echo %c% >a.txt

This can be executed once and added by 1 each time!
Floor 32 Posted 2008-01-06 00:03 ·  中国 广东 深圳 福田区 电信
中级用户
★★
Credits 369
Posts 87
Joined 2003-09-14 00:00
22-year member
UID 9822
Gender Male
Status Offline
Upstairs, it seems this can't be used under DOS 6.22 and DOS 7.1, right?
Floor 33 Posted 2008-01-06 00:05 ·  中国 广东 深圳 福田区 电信
中级用户
★★
Credits 369
Posts 87
Joined 2003-09-14 00:00
22-year member
UID 9822
Gender Male
Status Offline
### 1. First, translate the Chinese part:
- “请教:fc是什么命令?哪里有得下?” is translated as “Ask: What is the fc command? Where can I download it?”

So the overall result is:
Originally posted by everdos at 2008-1-5 08:21 PM:
Try fc

test1.bat
--------------------------------------------------------------------------------------------
@echo off
call test2.bat 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
...


Ask: What is the fc command? Where can I download it?
Floor 34 Posted 2008-01-06 09:58 ·  中国 江苏 无锡 电信
初级用户
Credits 52
Posts 21
Joined 2008-01-01 09:30
18-year member
UID 107370
Gender Male
Status Offline
fc is a standard DOS command used to compare the contents of two files. Just copy it from the DOS directory.

I don't know what the original poster wants to do. If you want to find a program that increments the content of A.txt by 1 each time it's executed, it's simple to write a program yourself.
Floor 35 Posted 2008-01-06 15:54 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Well, you can use fc to judge, just there are multiple temporary files. The dos7.1 of the webmaster is available.
第一高手 第二高手

Floor 36 Posted 2008-01-10 11:06 ·  中国 广东 深圳 龙岗区 电信
中级用户
★★
Credits 369
Posts 87
Joined 2003-09-14 00:00
22-year member
UID 9822
Gender Male
Status Offline
No FC found. Could the expert send me one? Email: hopeless_2005@126.com
Floor 37 Posted 2008-01-10 11:53 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Estimate this tfind line, my English is not good, take a look by yourself

http://home.mnet-online.de/horst.muc/int/find23.zip

--------------------------------------------------------------------
TFIND String search Ver 2.3 (c) 2001, Horst Schaeffer
--------------------------------------------------------------------

TFIND searches for strings, like MS-DOS FIND, with the following
differences:

* Several strings may be specified. TFIND will search for lines
where all given strings are found (Boolean AND).

* The search can be limited to a field in a fixed field
(i.e. column oriented) list; see option /F

* An extended search mode is available, where only letters and
digits are relevant (option /X)

* Alternative errorlevel with number of lines reported (option /E)

* Case ignored by default, Option /C for case sensitive search

* Only one single file may be given
(use FOR loop to scan several files)

* TFIND expects a text file with lines not exceeding 2048 bytes.
The file size is not limited.

* MS-DOS FIND Options /C (count) and /N are not supported.


Syntax:
-----------
TFIND "string" input file > output file

The input file will also be read from STDIN, Examples:

TFIND "something" FOO.TXT > RESULT.TXT
TFIND "something" < FOO.TXT > RESULT.TXT
dir | TFIND " " /F1,1 /V > RESULT.TXT

The command arguments are separated by blank space or comma; the
options may be placed anywhere. Strings must be enclosed in double
or single quote marks.

If several strings are given, TFIND selects the lines where all
strings were found (Boolean AND).

For a multiple file scan, use a FOR loop, e.g.:

for %a in (*.TXT *.ASC) do TFIND "something" %a >> RESULT.TXT

Use double redirection symbols to collect the results, and make sure
to delete the output file at the beginning (unless you want to keep
previous results). For file name headers see option /H or /L.


Options:
------------
/Fc,l Search is limited to a field (starting column c, length l)
The string must be completely within the given field.
Default length: rest of line

/C Case sensitive search (case ignored by default)

/V Select (and output) lines where the string was NOT found.
Opposite of the default, which is of course to output all
lines with hits.

/E Set errorlevel to number of lines reported (0..254)
Errorlevel 254 is returned for 254 or more.
Syntax error returns 255.
Note: With option /V as well, the number of lines is
relevant, NOT how many times the string was found!

Default mode: errorlevel 0: string was found, 1: not found

/H Header line with file name. This option is recommended when
files are scanned with a FOR loop. A header is not produced
if there is no output.
Note that MS-DOS FIND writes this header line by default.
No header line generated when the file is read from STDIN.

By default a prefix with 10 dashes plus 1 blank space
is inserted (as with MS-DOS FIND).
/"prefix"
custom prefix string. Use /"" if you want no prefix.

/L Same as /H, however with LFN and full path (Win9x/2000 only)

/X Extended search (see below)


Extended search:
--------------------
With option /X anything but letters and digits is removed from the
lines as well as from the given search string,

i.e. "X-25" is the same as "X #25" or "X25"
"100 Kg" is the same as "100KG"
"03/12/2001" is the same as "03-12-2001" or "03122001"
"preselect" is the same as "pre-select"

There is only one exception: blank space is not removed from the
source line, when occurring between letters, i.e. words in normal
text remain separated. This means:

"newspaper" will NOT find "news paper"

For convenience (when the keywords are specified by user input,
for example), several search strings are not required as individual
strings in quote marks, but may be specified in one pair of quote
marks, and separated by blank space.

i.e. TFIND "foo any X-25" /X
works the same way as TFIND "foo" "any" "X-25" /X

Note that this is only possible with option /X.

Important:
The extended search may produce unwanted hits sometimes. This mode
is meant to preselect lines for further choice by the user.


Language support
--------------------
Upper case conversion is handled for the standard character set
(codepage 437). See CASE103.PAT for country specific modifications.

A special German version is available that handles "Umlauts" in
extended search ("? = "ae" etc.)


*** 15 JUL 2001
第一高手 第二高手

Floor 38 Posted 2008-01-10 20:26 ·  中国 上海 宝山区 电信
初级用户
Credits 52
Posts 21
Joined 2008-01-01 09:30
18-year member
UID 107370
Gender Male
Status Offline
Uploaded a dos6.22's fc.exe to the public download area of http://greenerycn.ys168.com/.
Also, uploaded a Borland C++ 3.1's grep.com. grep.com can be used as follows:

grep -w 1 A.txt
if errorlevel 1 goto notfound

(-w means to match whole words)
Floor 39 Posted 2008-01-11 14:44 ·  中国 广东 深圳 龙岗区 电信
中级用户
★★
Credits 369
Posts 87
Joined 2003-09-14 00:00
22-year member
UID 9822
Gender Male
Status Offline
Forum Jump: