Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 在批处理文件中使用echo在单行中合并输出_Batch File_Echo - Fatal编程技术网

Batch file 在批处理文件中使用echo在单行中合并输出

Batch file 在批处理文件中使用echo在单行中合并输出,batch-file,echo,Batch File,Echo,我想修改下面的脚本,给我一个类似的输出 Number of processes on machine1 are 1 Number of processes on machine2 are 3 Number of processes on machine3 are 7 Number of processes on machine4 are 2 有人能帮忙吗 =============================== @echo off setlocal enabledelayedexp

我想修改下面的脚本,给我一个类似的输出

Number of processes on machine1 are 1

Number of processes on machine2 are 3

Number of processes on machine3 are 7

Number of processes on machine4 are 2
有人能帮忙吗

===============================

@echo off
setlocal enabledelayedexpansion

pushd "%~dp0"

echo %date% %time% 

TASKLIST /S machine1 | grep -c "process" 
TASKLIST /S machine2 | grep -c "process" 
TASKLIST /S machine3 | grep -c "process" 
TASKLIST /S machine4 | grep -c "process" 

=====================================

您可以使用filter if IMAGENAME命令为您提供必要的处理。
@echo off
setlocal enabledelayedexpansion

pushd "%~dp0"

echo %date% %time% 

TASKLIST /S machine1 | grep -c "process" 
TASKLIST /S machine2 | grep -c "process" 
TASKLIST /S machine3 | grep -c "process" 
TASKLIST /S machine4 | grep -c "process" 
我使用for命令是因为IMAGENAME的输出行为奇怪…它总是显示在行的开头

@echo off 
set compName1=machine1
for /f %%a in ('tasklist /NH /FO CSV /FI "IMAGENAME eq process" ^| find /C /V ""') do (
    echo Number of processes on %compName1% are %%a
)

你在windows下有grep吗?请编辑你的代码以确保可读性。例如,将任何代码缩进四个空格。然后,它以灰色突出显示。