在Windows中切割-c等效

时间:2017-11-13 19:41:22

标签: android bash

我正在尝试使用Android studio运行日志。我的公司使用Mac,但我有一台PC。我们使用一个命令来运行这些日志,我试图找到该命令的Windows版本。

代码是:

  

adb logcat | grep' adb shell ps | grep com.company.company |切-c10-15' >> /Users/all/Desktop/android.log

我已经知道grep应该更改为findstr,但是,我找不到等同于cut命令的窗口。

我也不是100%确定shellps是什么。

2 个答案:

答案 0 :(得分:0)

要在Windows中拥有强大的脚本环境,您可以使用PowerShell。 使用PowerShell,您可以使用以下脚本打开文件并拆分行:

$filename = "myfile.txt"

Get-Content $filename | ForEach-Object {
    $_.split(" ")[1]
}

Get-Content是cat的替代品,split()是cat的替代品。 Get-Content的输出通过管道输送到forEach-Object循环!!

答案 1 :(得分:0)

答案显示等效于 切-d“” -f2 (使用空格作为分隔符,返回第二个字段-first为[0]-) 这不是要求的: 切-c10-15 (返回从10号到15号的字符,都包括在内)