中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » 如何获得命令执行后返回的值
« [1] [2] [3] »
作者:
标题: 如何获得命令执行后返回的值 上一主题 | 下一主题
logan0279
初级用户





积分 100
发帖 45
注册 2007-12-11
状态 离线
『第 31 楼』:  

@echo off
for /f %%b in (a.txt) do set c=%%b
set /a c+=1
echo %c% >a.txt

这个就可以执行一次加一次1了!

2008-1-5 23:32
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
kavenlee72
中级用户




积分 369
发帖 87
注册 2003-9-14
状态 离线
『第 32 楼』:  

楼上的,你这个好象不能在DOS6.22及DOS7.1下使用吧

2008-1-6 00:03
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
kavenlee72
中级用户




积分 369
发帖 87
注册 2003-9-14
状态 离线
『第 33 楼』:  



  Quote:
Originally posted by everdos at 2008-1-5 08:21 PM:
用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
...

请教:fc是什么命令?哪里有得下?

2008-1-6 00:05
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
everdos
初级用户





积分 52
发帖 21
注册 2008-1-1
状态 离线
『第 34 楼』:  

fc是DOS标准命令,用于比较两个文件的内容,去DOS目录里拷贝过来就行了。
不知道楼主想做什么用,如果是想找个程序,每执行一次就将A.txt里面的内容加1,自己编个程序就简单多了。

2008-1-6 09:58
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
fastslz
铂金会员

DOS一根葱


积分 5493
发帖 2315
注册 2006-5-1
来自 上海
状态 离线
『第 35 楼』:  

恩可以用fc来判断,只是多个临时文件,fc站长的dos7.1里有



第一高手    第二高手

2008-1-6 15:54
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
kavenlee72
中级用户




积分 369
发帖 87
注册 2003-9-14
状态 离线
『第 36 楼』:  

未找到FC,请大侠能给我发一个,邮箱:hopeless_2005@126.com

2008-1-10 11:06
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
fastslz
铂金会员

DOS一根葱


积分 5493
发帖 2315
注册 2006-5-1
来自 上海
状态 离线
『第 37 楼』:  

估计这个tfind行的,我英文不好,自己看看吧
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 [options] "string" ["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



第一高手    第二高手

2008-1-10 11:53
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
everdos
初级用户





积分 52
发帖 21
注册 2008-1-1
状态 离线
『第 38 楼』:  fc.exe

上传了一个dos6.22的fc.exe到http://greenerycn.ys168.com/的公开下载区。
另外,传了一个Borland C++ 3.1的 grep.com上去,grep.com可按如下方式使用:

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

(-w表示要全字匹配)

2008-1-10 20:26
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
kavenlee72
中级用户




积分 369
发帖 87
注册 2003-9-14
状态 离线
『第 39 楼』:  

谢谢!试一下

2008-1-11 14:44
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
« [1] [2] [3] »
请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: