标签: nushell

获取 Nu shell 中的当前脚本位置

在 bash 中,您可以使用$0变量来获取当前脚本的位置。我如何在 Nu 中做同样的事情?echo $nu似乎没有什么我可以使用的。

shell nushell

8
推荐指数
1
解决办法
1003
查看次数

如何删除 Nushell 中的特定历史记录条目?

鉴于 Nushell 中存在这样的历史记录,我如何删除特定条目?例如条目 6、8 和 10?

\n
nu > history\n\xe2\x95\xad\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x95\xae\n\xe2\x94\x82  # \xe2\x94\x82      command       \xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xbc\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xa4\n\xe2\x94\x82  0 \xe2\x94\x82 history --clear    \xe2\x94\x82\n\xe2\x94\x82  1 \xe2\x94\x82 php --version      \xe2\x94\x82\n\xe2\x94\x82  2 \xe2\x94\x82 composer --version \xe2\x94\x82\n\xe2\x94\x82  3 \xe2\x94\x82 node --version     \xe2\x94\x82\n\xe2\x94\x82  4 \xe2\x94\x82 npm --version      \xe2\x94\x82\n\xe2\x94\x82  5 \xe2\x94\x82 composer --version \xe2\x94\x82\n\xe2\x94\x82  6 \xe2\x94\x82 history            \xe2\x94\x82\n\xe2\x94\x82  7 \xe2\x94\x82 php --version      \xe2\x94\x82\n\xe2\x94\x82  8 \xe2\x94\x82 history            \xe2\x94\x82\n\xe2\x94\x82  9 \xe2\x94\x82 php --version      \xe2\x94\x82\n\xe2\x94\x82 10 \xe2\x94\x82 history            \xe2\x94\x82\n\xe2\x94\x82 11 \xe2\x94\x82 composer --version \xe2\x94\x82\n\xe2\x95\xb0\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xb4\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x95\xaf\n
Run Code Online (Sandbox Code Playgroud)\n

nushell

7
推荐指数
2
解决办法
952
查看次数

如何从 nushell 运行 powershell 命令

在我的Windows环境中安装nushell(https://www.nushell.sh/)后,我想与powershell结合使用nushell的强大功能。

例如,我需要在日常工作中调用常见的powershell命令,例如

> get-service *myservice -computername remote | restart-service
Run Code Online (Sandbox Code Playgroud)

但是如何从 nu shell 调用这样的命令(使用管道)?

我需要从 powershell 启动 nu shell 还是反之亦然?另外,使用 ^ 符号的调用似乎不起作用。我总是收到“命令未找到”的消息,并且可以肯定它不是 DOS 命令。

如果能在 Windows 上同时获得两个世界的力量就好了……nu shell 和 powershell

windows shell powershell nushell

6
推荐指数
1
解决办法
1246
查看次数

6
推荐指数
1
解决办法
783
查看次数

如何在 Nushell 中过滤分组依据的值列中的行数?

我想做 SQL 中 HAVING 子句的等效操作。现实生活中的描述是我正在尝试查找指向两个(或更多)索引及其索引名称的 Elasticsearch 别名。数据看起来像这样

\n

我首先执行group by,然后对它们进行透视以获取行,其中第一列是组键,第二列是包含 n 行的表。获取该表的命令是open file.txt | lines | split-column " " --collapse-empty Alias Index | group by Alias | pivot

\n
 \xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n # \xe2\x94\x82 Column0       \xe2\x94\x82 Column1\n\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xbc\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xbc\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n 0 \xe2\x94\x82 abcd_20200430 \xe2\x94\x82 [table 1 rows]\n 1 \xe2\x94\x82 abcd_20200501 \xe2\x94\x82 [table 3 rows]\n 2 \xe2\x94\x82 abcd_20200502 \xe2\x94\x82 [table 2 rows]\n 3 \xe2\x94\x82 abcd_20200503 \xe2\x94\x82 [table 1 rows]\n 4 \xe2\x94\x82 abcd_20200504 \xe2\x94\x82 [table 1 rows]\n
Run Code Online (Sandbox Code Playgroud)\n

我想按 Column1 具有超过 1 …

elasticsearch nushell

4
推荐指数
1
解决办法
576
查看次数

Nushell 中的 while/until 循环

作者注:此问题使用旧版本 Nushell 中过时的语法和语句。请参阅下面的答案以了解更新的语法。

Nushell 脚本中如何执行 while/until 循环?

由于 Nushell 有一个相当令人惊叹的表/JSON 解析系统,我一直在尝试通过它使用Stack Exchange API

第一个挑战是循环访问 API 调用的多个可能的结果页面。我的(通常是程序性的,有时是面向对象的)背景让我在 Nushell 中找到了一个构造,例如:

let page = 1
let re = (http (echo "/2.3/questions?fromdate=1648771200&todate=1648944000&order=desc&sort=activity&site=askubuntu&page=" $page) | from json)
let questions = $re.items

while ($re.has_more) {
    let page = page + 1
    let re = (http (echo "/2.3/questions?fromdate=1648771200&todate=1648944000&order=desc&sort=activity&site=askubuntu&page=" $page) | from json)
    let questions = $questions | append $re.items
}
Run Code Online (Sandbox Code Playgroud)

...或等效的until构造。

我如何在 Nushell 中实现这一点?

注意 -在上面的示例中使用httpiegzip ,因为它会自动处理Stack API 所需的压缩( …

while-loop until-loop nushell

3
推荐指数
1
解决办法
938
查看次数