问题描述
有没有办法在Windows XP上仿效unix剪切命令,而不使用cygwin或其他非标准的Windows功能?
Is there a way to emulate the unix cut command on windows XP, without resorting to cygwin or other non-standard windows capabilities?
示例:使用tasklist / v ,通过窗口标题找到特定的任务,然后从该列表中提取PID以传递给taskkill。
Example: Use tasklist /v, find the specific task by the window title, then extract the PID from that list to pass to taskkill.
推荐答案
FYI,tasklist和taskkill已经有过滤功能:
FYI, tasklist and taskkill already have filtering capabilities:
tasklist /FI "imagename eq chrome.exe"
taskkill /F /FI "imagename eq iexplore.exe"
如果你想要更一般的功能,批处理脚本。例如:
If you want more general functionality, batch scripts (ugh) can help. For example:
for /f "tokens=1,2 delims= " %%i in ('tasklist /v') do (
if "%%i" == "%~1" (
echo TASKKILL /PID %%j
)
)
Windows命令行有很多帮助。输入帮助获得一个简单的摘要的命令列表,然后键入帮助有关该命令的更多信息(例如帮助)。
There's a fair amount of help for the windows command-line. Type "help" to get a list of commands with a simple summary then type "help " for more information about that command (e.g. "help for").
这篇关于使用标准的Windows命令行/批处理命令模拟unix'cut'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!