在 DOS 中获取文件同一行的输出?

发布于 2024-08-15 04:38:29 字数 475 浏览 4 评论 0原文

如果我想将两个来源的输出放在同一行上,我该怎么做?

就我而言,我有一个文件和一个程序。该文件是这样的:

listOfThings=

我的程序在一行上输出字符串列表。我想要一个每晚运行的小脚本,将这两件事放在一行上。我无法弄清楚如何正确执行此操作,但

示例批处理文件

type header.txt > outputfile.txt
myProgram >> outputfile.txt

会导致以下结果:

listOfThings=
foo bar baz etc

我确实需要输出文件将列表立即跟在 = 之后,但我不知道如何使用 > 来做到这一点>操作员。 (在有人建议之前,我不能做类似在 listOfThings= 行末尾添加 \ 的事情,这对我想做的事情不起作用)

If I have output from two sources that I want to put together on the same line, how would I do that?

In my case I have a file and a program. The file is something like this:

listOfThings=

My program outputs a list of strings on a single line. I want have a small script that runs nightly to put these two things together on a single line. I can't figure out how to do this right though

example batch file

type header.txt > outputfile.txt
myProgram >> outputfile.txt

which results in this:

listOfThings=
foo bar baz etc

I really need the output file to have the list immediately follow the =, but I can't figure out how to do it with the >> operator. (and before anyone suggests it, I can't do something like put a \ on the end of the listOfThings= line, that won't work for what I'm trying to do)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泛泛之交 2024-08-22 04:38:29

您需要确保 header.txt 的内容中没有回车换行符对。用十六进制编辑器查看并确保其中没有 0x0d0a。

You need to make sure that the contents of header.txt does not have a carriage return linefeed pair in it. Look at it with a hex editor and make sure there is no 0x0d0a in it.

最终幸福 2024-08-22 04:38:29

您是否确保 header.txt 中根本没有任何行分隔符? (即,= 是文件的最后一个字节)。

另外,请尝试将 header.txt 复制到 outputfile.txt,以防 type 自行附加换行符。

Have you made sure that header.txt doesn't have any line separators in it at all? (Ie, the = is the very last byte of the file).

Also, try copying header.txt to outputfile.txt in case type is appending a line feed on it's own.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文