powershell输出文件到文本文件单行? [英] powershell out file to text file single line?

查看:46
本文介绍了powershell输出文件到文本文件单行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$Date2,$Difference | Out-File $To2\Outputfile.txt -Append -width 200

导致我的输出在 2 行的文本文件中,如下所示,但是我希望在一行中以另一行开头

Resulting my output in text files in 2 lines as below in, however i am expecting in one line start with another line

Friday, August 22, 2014 5:21:05 PM 00:00:07.4255524
Friday, August 22, 2014 5:22:15 PM 00:00:06.1931603

非常感谢任何帮助

推荐答案

我认为问题在于,".使用这个 "$Date2,$Difference" |Out-File $To2\Outputfile.txt -Append -width 200

I think the problem is the ",". Use this "$Date2,$Difference" | Out-File $To2\Outputfile.txt -Append -width 200

在您的示例中,您将一个数组传递给管道,其中包含两个元素 $Date2,$Difference 这将使右侧的语句为每个元素触发一次.创建单个字符串会将输出一起添加到文件中.

In your example you are passing an array to the pipe with two elements $Date2,$Difference which will make the statement on the right fire once for each element. Creating a single string will add the output together in the file.

这篇关于powershell输出文件到文本文件单行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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