0

In powershell, is there a difference between:

ps theProcessName* | kill

and

kill -processname theProcessName*

Thanks

2

Effectively, the answer is "no."

ps [processname] | kill will query for a list of objects matching 'processname' and pass those objects to the kill command.

kill -processname [processname] will kill all processes matching 'processname'.

The only difference is how the commands work on the backend. For ps [processname] | kill, Powershell will first perform a Get-Process command, then pass it to kill. kill -processname [processname] will simply issue a Stop-Process command, without querying for their existence first.

Short answer: they will both perform the same task. the straight kill command is very slightly faster, because one step is skipped.

1

Well, "ps processname" doesn't do anything. And "kill -p" doesn't kill. It prints.

  • 1
    powershell, not bash; – Hyppy Jun 18 '12 at 13:52
  • right, I edited my question that it's in powershell – jon Jun 18 '12 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.