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.The Windows equivalents of the most used Linux commands
51–60 of 72 posts
Re: The Windows equivalents of the most used Linux commands
#52Earlier 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.
Re: The Windows equivalents of the most used Linux commands
#53https://learn.microsoft.com/en-us/windows/wsl/filesystems#ru...
Re: The Windows equivalents of the most used Linux commands
#54Earlier 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.
Re: The Windows equivalents of the most used Linux commands
#55Earlier 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.
Re: The Windows equivalents of the most used Linux commands
#56Not 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.
Re: The Windows equivalents of the most used Linux commands
#57Why 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
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
#58Or you can just prepend `wsl` to the linux command you want to run; of course only if you have wsl setup. https://learn.microsoft.com/en-us/windows/wsl/filesystems#ru...
Re: The Windows equivalents of the most used Linux commands
#59Let 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…