Hacker News new | past | comments | ask | show | jobs | submit login

Can you summarize Powershell for someone to doesn't get it?



Sure.

   ps <processname> | kill
You piped the object to kill, not the text, so you didn't need a regex. Kill takes an process object as input and kills it. You could probably do that with a subshell on a nix box, which is only a little more ugly, but what about getting processes that have an RSS above a certain size?:

    ps | where-object { $_.WS -gt 500MB } | kill
where-object is a filter, WS is the Windows equivalent of RSS. You've just picked only the objects with an RSS greater than 500MB. No regexs turning text into numbers, no math to turn KB into MB. Just filtering the content based it's properties, not its presentation.

I actually don't use Windows for development as I don't like the languages or the lockin (I've never been able to find something as good as Python on Linux, including IronPython) but I quite like Powershell.


That's very Lispy, actually.

  (defun ps (process-name)
    (labels ((find-proc (name)
  	     (remove-if-not 
  	      (lambda (x) 
  		(string= (bt:thread-name x) name))
  	      (bt:all-threads))))
      (first (find-proc process-name))))
  
  (defun kill (process)
    (bt:destroy-thread process))
        
  ;; usage
  (kill (ps "init"))

And if you remake PS into a generic function you can dispatch on various input types, not just find process by name.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: