A Saner Windows Command Line
111–120 of 164 posts
Re: A Saner Windows Command Line
#112Earlier quoted context omitted.
I've only been working professionally with linux for 5-ish years, but i'd say that i'm still at the "2 googles per command" number for bash. Some of it stems from the fact that i just don't use it enough, but most of it from the fact that this shit just isn't intuitive. why is -b the flag for key length in ssh-keygen? Why is -v the flag for "don't include" in grep? I have those memorized now, but there is no way they…
> why is -b the flag for key length in ssh-keygen? Because the length is given in "bits". I get your point, but that's a terrible example! :-)
But the point is that even though it's most likely "my fault" for not reading the manual correctly (i'm not saying you were implying that, but often i do feel that it's ultimately because of my laziness that i have these problems), they aren't "intuitive" in the sense that that you can just pick it up and go.
The one thing my "dream linux" system would borrow from powershell is the tab-completion for flags and sub-commands.
If i could type `git ` and hit tab and see a list of what is possible (with a quick one-sentence explanation of that sub-command) it would completely turn my experience around.
But even that takes "domain knowledge" that tab auto-completes... This stuff is hard!
Re: A Saner Windows Command Line
#113Sure, I'm not thrilled with having to learn another language to get anything done. But it's so much better than what came before that I don't care. Besides, Bash and friends certainly have their quirks as well.
Re: A Saner Windows Command Line
#114Earlier quoted context omitted.
Got a directory full of files with underscores in the names? Want spaces instead? Easy, type this: dir -recurse | where {-Not $_.PsIscontainer -AND $_.name -match "_"} | foreach { $New=$_.name.Replace("_"," ") Rename-Item -path $_.Fullname -newname $New -passthru } EDIT: I purposely posted the first Google result. You obviously Googled as well as your code got it backward. But really, why isn't it this? It's worked s…
Dir | rni –NewName { $_.name –replace " ","_" } That command does some extra stuff, which would make the bash equivalent also complicated.
dir -rec -file | rni –newname { $_.name –replace "_"," " }
Edit: Oops, request did not include recursive, the original sample solution did.FWIW top Google results for "unix recursively rename files" give below solutions (slightly different scenarios but you get the idea). Not particularly shorter, or less cryptic:
find . -iname "*dbg*" -exec rename _dbg.txt .txt '{}' \;
shopt -s globstar nullglob
rename _dbg.txt .txt **/*dbg*Re: A Saner Windows Command Line
#115Earlier quoted context omitted.
Haven't used PS much – only used DuckDuckGo to find what each PS command meant, so it's possible I have misuderstood some, but – these are the bash alternatives, I think: | :PowerShell | Bash: | |Tab completion | built-in, OOTB| |Get-help | `help`| |get-command | `apropos -s .`| |show-command | ` --help` or `man `| |get-member | Inapplicable; text has a structure. Use `head -1` to find out, given structure is printed…
What's the bash equivalent of something like this? Get-Command -Module SQLPS | ?{$_.Parameters.Values.ParameterType -contains [PSCredential]} In PowerShell, this means "show me all the commands from the SQLPS module that take a credential object as one of the parameters".
Print all files in package: `dpkg -L ` (for Debian based OSes)
Filter executable commands: ` | grep 'bin/.'` (assuming the package adheres to standards)
Check parameters of command: ` --help` (again, assuming the developers have adhered to convention)
Of course, if one needs to check multiple commands, one will have to use a loop. (Which is basic programming, isn't it?).
Re: A Saner Windows Command Line
#116Re: A Saner Windows Command Line
#117Git for Windows is bundled with Git-Bash. A very Linux-like commande line. Works like a charm. I also use MobaXTerm as my Putty replacement. It also comes with a Bash terminal that works fine. Very handy! (Two reasons why I love to have learnt Bash)
Granted, bash may not be the most intuitive shell ever, but it just works about everywhere and this is a huge advantage when switching OS regularly.
Re: A Saner Windows Command Line
#118Earlier quoted context omitted.
You're missing my point.
Could you please be more explicit about it then? The part about the .NET objects has already been addressed by others, and I actually like that -- right now at work we're wrestling with a few command line applications that output text (in full UNIX-style) and it's a mess to parse the thing, because it's so badly documented. If we had objects as a result it'd be glorious (not that PS would help, this isn't a bash scri…
Sure, it doesn't work with CPython. I shouldn't need to be that explicit though, bring up IronPython is one hell of a nit.
Re: A Saner Windows Command Line
#119Earlier quoted context omitted.
Dir | rni –NewName { $_.name –replace " ","_" } That command does some extra stuff, which would make the bash equivalent also complicated.
Yep. Technically the request included recursive rename, and to avoid renaming directories, but gosh that's not hard: dir -rec -file | rni –newname { $_.name –replace "_"," " } Edit: Oops, request did not include recursive, the original sample solution did. FWIW top Google results for "unix recursively rename files" give below solutions (slightly different scenarios but you get the idea). Not particularly shorter, or…
When you Google a PowerShell problem the Google results come back looking insane. You can play code golf here all you want but even this version looks nuts to outsiders.
It's a cultural problem. You don't solve it by shouting subtly-differing versions of your culture, louder.
Re: A Saner Windows Command Line
#120Earlier quoted context omitted.
Languages are not the same, you'll never have interoperability; try exporting a .NET object with a 64-bit integer to be consumed by JavaScript, for example. Text wins.
PS C:\> 0x1234567812345678 1311768465173141112 PS C:\> 0x1234567812345678 >.\foo.txt ; cat .\foo.txt 1311768465173141112 PS C:\> "WScript.Echo('$(0x1234567812345678)')" >.\foo.js ; cat .\foo.js ; cscript //nologo .\foo.js WScript.Echo(1311768465173141112) 1.31176846517314E+18 ... I'm not seeing your point.
JavaScript does not have 64-bit integers. So if you exported an object with 64-bit integers to XML, for example, a JavaScript program could not (correctly) deserialize that XML.