TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Getting work done with PowerShell on Linux

37 点作者 Decabytes大约 2 年前

13 条评论

dopylitty大约 2 年前
“Cmdlets return objects not text, making it easier to access specific components of the returned object”<p>This is for me the key value of shells like PowerShell.<p>Uncountable billions of person hours have been wasted parsing the text output of common *nix commands. It’s time to move away from the “everything is text with random formatting” philosophy.
评论 #34911398 未加载
评论 #34911220 未加载
评论 #34911413 未加载
评论 #34911353 未加载
评论 #34937003 未加载
DangitBobby大约 2 年前
If you see this and think &quot;being able to easily manipulate CSVs and other files in the shell would be really nice&quot; you should definitely check out nushell.
评论 #34911830 未加载
fnovd大约 2 年前
Very cool, but even so it&#x27;s hard to see the benefit of learning PowerShell just for Linux. Interacting with objects instead of text is definitely a huge plus. However, the main benefit of bash is the portability. If you have to set up a special scripting environment on every machine you&#x27;re working with, you&#x27;re better off setting up something with a &quot;proper&quot; language instead (as noted by the author). If I&#x27;m willing to give up the ability to dump my script in an unconfigured environment and have it work, PowerShell is nowhere near the top of my list.<p>If you spend most of your time in the Windows ecosystem, then there&#x27;s no reason <i>not</i> to learn it. If I had cut my chops with PowerShell instead of bash I&#x27;m sure I&#x27;d be clamoring for some kind of LSW system. There&#x27;s a reason why things went the other way, though. I don&#x27;t think we&#x27;re going to get Rust bindings for C, either.
评论 #34911307 未加载
评论 #34915674 未加载
评论 #34911843 未加载
评论 #34911332 未加载
donatj大约 2 年前
&gt; For some people a one-hundred-line shell script is too long. For others, that’s a regular day. But most people would probably agree that a 10,000 line shell script should probably have been written in a more robust programming language. So why the contention?<p>I mean maybe. My big thing is single responsibility.<p>My suspicion is if you wrote 10,000 lines of shell script that should probably be like 20+ individual scripts and you&#x27;ve written something with way too many responsibilities.<p>A script should do a single thing.
评论 #34911919 未加载
jmbwell大约 2 年前
Powershell is often underutilized. It’s absolutely worth being conversant in it if Windows or Azure are part of your environment. And being able to work directly in Powershell from my Mac is just great, versus having to remote into a Windows machine.<p>I’m not switching all of my workflows to Powershell. That would be silly. I’m honestly not particularly inclined to use Powershell unless I have no other option. But it’s a valuable tool in the box. As are Python and (lately for me) zsh. And as with anything else, it’s worth knowing how to get the most out of it.<p>This article isn’t bad. I also found Powershell in a Month of Lunches to be helpful at demystifying it.
pipeline_peak大约 2 年前
&quot;PowerShell became a huge reason why Microsoft was able to succeed in the cloud computing market&quot;<p>um...Really?
评论 #34911408 未加载
评论 #34911548 未加载
评论 #34911782 未加载
Flipflip79大约 2 年前
Obviously, this is a totally subjective opinion without much critical thought - but for me PowerShell is just...ugly. Its ugly to write, the PowerShell Terminal in Windows is aesthetically ugly (the blue, yellow, and red). Error output is verbose (good) but awfully formatted. The whole thing just makes it feel &quot;cheap&quot; to me. Find it really hard to get over that bias now when I need to work in PS.
评论 #34911875 未加载
评论 #34911826 未加载
评论 #34915724 未加载
评论 #34912387 未加载
password4321大约 2 年前
I stick with PowerShell on Windows and miss its forgiveness of case sensitivity and slash direction issues for tab complete in other shells.
jmclnx大约 2 年前
I am curious over what eventually happened to Jeffrey Snover. Was he justly compensated for his work ?<p>Did a search, and seems he was eventually promoted:<p><a href="https:&#x2F;&#x2F;www.spiceworks.com&#x2F;tech&#x2F;tech-general&#x2F;news&#x2F;jeffrey-snover-quits-microsoft&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.spiceworks.com&#x2F;tech&#x2F;tech-general&#x2F;news&#x2F;jeffrey-sn...</a>
评论 #34911693 未加载
geophile大约 2 年前
Marcel (<a href="https:&#x2F;&#x2F;marceltheshell.org" rel="nofollow">https:&#x2F;&#x2F;marceltheshell.org</a>) is a shell designed around the idea of piping objects instead of strings, in a way that should be more familiar to Linux users. It is designed to be bash-like. Instead of learning sublanguages (awk, find, etc.), customization is done by Python, and in fact, it is Python objects that are piped between commands.<p>To take an example from the article, here is the marcel code to read penguins.csv and get unique species values, sorted:<p><pre><code> read -c penguins.csv | map (species, *: species) | unique | sort </code></pre> Or to find species = &#x27;gentoo&#x27;:<p><pre><code> read -c penguins.csv | select (species, *: species == &#x27;gentoo&#x27;) </code></pre> &quot;read -c penguins.csv&quot; reads the file, but instead of returning strings, -c causes each line to be parsed into a Python tuple.<p>In both cases, parens delimit a Python lambda (you can omit or include &quot;lambda&quot;). &quot;species, *&quot; binds species to the first value of a field, and * to a tuple of the remaining fields. So &quot;map (species, *: species)&quot; maps the row to just the value of the species column. &quot;select (species, *: species == &#x27;gentoo&#x27;)&quot; uses a Python expression to select rows with species &#x27;gentoo&#x27;.<p>You can also do grouping and aggregation in marcel. For example, this command locates files recursively, obtains the extension and size of each, groups by extension, and then sums sizes for each extension:<p><pre><code> ls -fr | map (file: (file.suffix, file.size)) | red . + </code></pre> &quot;ls -fr&quot; lists everything recursively (-r), yielding only files (-f). A stream of File objects is piped to map, which maps each File to an (extension, size) tuple. &quot;red . +&quot; does reduction (i.e., grouping and aggregation. The &quot;.&quot; specifies that the first part of the input tuple, the extension, is used for grouping, and the second part, the file size, is aggregated using +.
josteink大约 2 年前
I’ve found PowerShell the easiest way to automate and power CI&#x2F;CD in a mixed Windows, Mac and Linux environment.<p>It feels kinda weird at first, but then you install the LSP server for it in your editor, and suddenly things start feeling way more solid and reliable than bash.<p>I’ve come to appreciate it more than I expected.
app4soft大约 2 年前
&gt; <i>For example typing…</i><p><pre><code> set-location ~ </code></pre> &gt; <i>On PowerShell in Linux and…</i><p><pre><code> cd ~ </code></pre> &gt; <i>on Windows both send you to whatever your Home directory is.</i><p>Is not it vice versa?<p>I mean, on Linux it is `cd ~` and on Windows `set-location ~`, no?
评论 #34911985 未加载
评论 #34913003 未加载
aib大约 2 年前
I would really like to try PowerShell, especially since it has a different paradigm than the &quot;text&quot; shells that I&#x27;m used to---but Microsoft&#x27;s name behind it gives me pause. I can&#x27;t rationalize it except for that every MS technology I&#x27;ve tried turned out to be tailored for a different class of user---lower-skilled and MS-paying. There&#x27;s a high chance this itself is irrational, but if it blocks it blocks.
评论 #34912548 未加载