我如何使用COPY命令附加到文件 [英] How do I append to a file using the COPY command

查看:210
本文介绍了我如何使用COPY命令附加到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行Windows 7旗舰版64位,但我的经验可以追溯到DOS 3.0。

由于类似DOS 3.1,你已经能够文件到另一个追加本使用COPY命令:

  COPY FILE1 + FILE2 = FILE1

制作一个临时FILE3不必要的需求。

这是因为,只要你加入,你经常需要更新您的 CONFIG.SYS AUTOEXEC.BAT 文件。

这也曾经是获得正确的顺序是importiant,否则你会最终得到一个空文件1。

但是今天,当我试过了,它留下文件1 不变,当我颠倒了顺序,它(可以理解)制成文件1 的副本文件2

有谁知道,如果它被替换为另一种方法,当这种变化发生?

编辑:

我一直在做更多的测试,奇怪的是,尽管上述code将无法正常工作,你仍然可以从窗台控制台复制并追加了像这样一个现有的文件:

 拷贝文件1 +骗子=文件1
键入一些文本追加到file1
^ Z([CTRL] + Z结束文件字符中)

如果我的Windows版本搞砸不知何故,我不知道。任何机构可以复制我的发现?

编辑:

它适用于95/98 / ME / 2000 / XP / XP模式/ 7专业版x64 / x64的8。所以我想,这不是一个 7旗舰版64位问题,而是与我的机器的问题。

* 的叹息*

编辑:

最后编辑,我保证。 :)

这是不是我的机器的问题,它是与文件1的问题。显然,当我第一次附加文件2到它时,[CTRL] + Z(EOF字符)从未被覆盖,导致文件看起来像这样:

 原始数据
原始数据
[EOF]
附加数据
附加数据
附加数据

您可以自己从在命令提示符下实验重复这一点。 (其中^ Z是字符[CTRL] + Z)

在命令提示符下键入:

 复制CON文件1
文件中的一个
^ Z ^ Z副本CON文件2
文件中的两个
^ Z副本CON文件3
文件中的三个
^ Z复制文件1 +文件2 =文件1复制文件2 +文件3 =文件2TYPE文件1
TYPE文件2

您将看到:

文件1

 文件中的一个

文件2

 文件中的两个
文件中的三个

您可以键入文件2>>文件1 或使用串联文件几乎任何其他方法,当你键入文件1 它仍然只是看起来包含文件一个。但是如果你使用查找搜索关键词文件来解析该文件它会告诉你什么是真正回事。在这种情况下键入:

 查找,文件1

和你会得到回报:

  ---------- FILE1
文件中的一个
→文件中的两个


解决方案

Windows 8的x86的:


微软的Windows [版本6.2.9200]
(C)2012 Microsoft公司。版权所有。C:\\用户\\尼科斯>回声富>文件1C:\\用户\\尼科斯>回音栏>文件2C:\\用户\\尼科斯>复制/ B文件1 +文件2文件1
文件1
文件2
        1文件(S)复制。C:\\用户\\尼科斯>类型文件1

酒吧

I'm running Windows 7 Ultimate x64, but my experience dates back to DOS 3.0.

Since like DOS 3.1 you've been able to append a file to another one with this use of the COPY command:

COPY FILE1+FILE2=FILE1

Making the need for a temporary FILE3 unnecessary.

It was a very convenient command since whenever you added a new program you often needed to update your CONFIG.SYS and AUTOEXEC.BAT files.

It also used to be that getting the order correct was importiant, otherwise you'd end up with an empty FILE1.

But today when I tried that, it left FILE1 untouched, and when I reversed the order, it (understandably) made FILE1 a copy of FILE2.

Does anyone know if it's been replaced with another method, and when this change happened?

EDIT:

I've been doing more testing, and oddly even though the above code won't work, you still can sill copy from the console and append that to an existing file like this:

copy file1+con=file1
Type some text to append to file1
^Z ([CTRL]+Z the End Of File character)

I'm wondering if my version of Windows is messed up somehow. Can any body replicate my findings?

EDIT:

It works on 95 / 98 / ME / 2000 / XP / XP Mode / 7 Professional x64 / 8 x64. So I imagine that it's not a 7 Ultimate x64 problem, but rather an issue with my machine.

* Sigh *

EDIT:

Last edit, I promise. :)

It was not an issue with my machine, it was an issue with File1. Apparently when I first appended File2 to it, the [CTRL]+Z (EOF character) never got overwritten, causing the file to look like this:

Original Data
Original Data
[EOF]
Appended Data
Appended Data
Appended Data

You can duplicate this yourself with the following experiment from at the command prompt. (Where ^Z is the character [CTRL]+Z )

At the command prompt type:

copy con file1
File One
^Z^Z

copy con file2
File Two
^Z

copy con file3
File Three
^Z

copy file1+file2=file1

copy file2+file3=file2

TYPE file1
TYPE file2

You will see:

file1

File One

file2

File Two
File Three

You can type file2 >> file1 or use nearly any other method of concatenating files, and when you type file1 it will still only appear to contain File One. BUT if you use FIND "searchterm" file to parse the file it will show you what's REALLY going on. In this case type:

FIND " " file1

And you will be rewarded with:

---------- FILE1
File One
→File Two

解决方案

Windows 8 x86:

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\Users\Nikos>echo foo>file1

C:\Users\Nikos>echo bar>file2

C:\Users\Nikos>copy /b file1 + file2 file1
file1
file2
        1 file(s) copied.

C:\Users\Nikos>type file1
foo
bar

这篇关于我如何使用COPY命令附加到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆