Live data from Hacker News

The Windows equivalents of the most used Linux commands

techkettle.blogspot.com

51–60 of 72 posts

Re: The Windows equivalents of the most used Linux commands

#51
Let me present you my favorite, how do you figure out dirname, basename and filename in batch script?

    set filepath="C:\some path\having spaces.txt"

    for /F "delims=" %%i in (%filepath%) do set dirname="%%~dpi" 
    for /F "delims=" %%i in (%filepath%) do set filename="%%~nxi"
    for /F "delims=" %%i in (%filepath%) do set basename="%%~ni"

    echo %dirname%
    echo %filename%
    echo %basename%
It is just as intuitive as one would expect.

Re: The Windows equivalents of the most used Linux commands

#52
post #37

Earlier quoted context omitted.

How often does plain 'kill ' not work, but some other signal other than SIGKILL works? Usually the process is either working correctly and terminates when asked, or else not working correctly and needs to be KILLed.

It is possible to install a handler for most signals, and that handler can be configured to ignore the signal. Signal 9 cannot be ignored.

I don't think of 9 as really being a signal to the process at all, more of an instruction to the OS kernel to terminate the process

Re: The Windows equivalents of the most used Linux commands

#54
post #50

Earlier quoted context omitted.

Yuck. Just install WSL and be done with it

Underrated secondary option: git bash. Lower setup overhead than full WSL, although it is slower if you need to work on a lot of files or spawn a lot of processes.

Also, Minc, MinC is not Cygwin. And, yes slower, but it might work even under XP.

Re: The Windows equivalents of the most used Linux commands

#55
post #50

Earlier quoted context omitted.

Yuck. Just install WSL and be done with it

Underrated secondary option: git bash. Lower setup overhead than full WSL, although it is slower if you need to work on a lot of files or spawn a lot of processes.

I guess you get git bash for free when you install git, which speaks legions about the pain of powershell

Re: The Windows equivalents of the most used Linux commands

#56
post #3

Not bad, but one big criticism, never do a 'kill -9' first, that will stop the program from cleaning up after itself if killed using -9. Use one of these instead: -TERM then wait, if not -INT then wait, if not -HUP then wait, if not -ABRT If you are sure all of these fail, then use -9 (-KILL). But assume the program has a major bug and try and find another program that will do the same task and use that instead.

On a modern OS, doesn’t the kernel (eventually) take care of the cleanup anyways?

Re: The Windows equivalents of the most used Linux commands

#57

Why would you use CMD when Powershell exists?

Because powershell is weird and obtuse? Or because powershell works slightly different in the terminal va the powershell dev environment? Its a tool most of us use under duress rather than choice

I certainly won't argue that pwsh is even close to perfect, but...obtuse is just about the most unfitting description of powershell. It offers a level of structure and consistency that is - even with all its shortcomings - orders of magnitude above the wild west of the daily reality of the linux cli.

Just because it's the mess we are all intimately familiar with, doesn't make it less of a mess.

Re: The Windows equivalents of the most used Linux commands

#59
post #51

Let me present you my favorite, how do you figure out dirname, basename and filename in batch script? set filepath="C:\some path\having spaces.txt" for /F "delims=" %%i in (%filepath%) do set dirname="%%~dpi" for /F "delims=" %%i in (%filepath%) do set filename="%%~nxi" for /F "delims=" %%i in (%filepath%) do set basename="%%~ni" echo %dirname% echo %filename% echo %basename% It is just as intuitive as one would expe…

  $file = Get-ChildItem "C:\some path\having spaces.txt"

  Write-Output $file.DirectoryName
  Write-Output $file.Name
  Write-Output $file.BaseName
Or if that's still to verbose:

  $file = gci "C:\some path\having spaces.txt"

  echo $file.DirectoryName
  echo $file.Name
  echo $file.BaseName

People should really get over their aversion against powershell.

Re: The Windows equivalents of the most used Linux commands

#60

> Author's note: From here on, the content is AI-generated Kudos to the author for their honesty in admitting AI use, but this killed my interest in reading this. If you can use AI to generate this list, so can anyone. Why would I want to read AI slop? HN already discourages AI-generated comments. I hope we can extend that to include a prohibition on all AI-generated content. > Don't post generated comments or AI-edi…

I could've done better with research, but this post has been collecting dust in the drafts, so I decided to try my first (and last) time to finish the work I started a few months ago.
Post reply on HN