AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-4132818

Bryan Tan's questions

Martin Hope
Bryan Tan
Asked: 2025-04-22 09:24:35 +0800 CST

如何使用 aws cli --query 来使用 JMESPath 函数过滤项目?

  • 5

我一直在阅读https://docs.aws.amazon.com/cli/v1/userguide/cli-usage-filter.html和https://jmespath.org/specification.html上的文档,但它不起作用。

例如,我想使用 starts_with 来查找 DBInstances.DBInstanceIdentifier 以“foo”开头的数据库实例。

aws rds describe-db-instances --query 'DBInstances.DBInstanceIdentifier[?starts_with(@, "foo")]'
null
---
aws rds describe-db-instances --query 'DBInstances[?starts_with("DBInstanceIdentifier", "foo")]'

In function starts_with(), invalid type for value: None, expected one of: ['string'], received: "null"
---
aws rds describe-db-instances --query 'DBInstances[?starts_with(DBInstanceIdentifier, "foo")]'

In function starts_with(), invalid type for value: None, expected one of: ['string'], received: "null"

我还想使用诸如 contains 等函数来做其他事情,但这些函数似乎都不起作用。

我知道我可以通过 jq 传递输出,这是一个简单的解决方案,只是想了解更多工具

aws rds describe-db-instances | jq '.DBInstances[] | select(.DBInstanceIdentifier | startswith("foo"))'
  • 1 个回答
  • 31 Views
Martin Hope
Bryan Tan
Asked: 2025-04-02 07:34:05 +0800 CST

当负载高时,如何修复 sed 命令变得非常慢的问题?

  • 8

我有一个 bash 脚本,它采用一个简单的属性文件并将值替换到另一个文件中。 (属性文件只是'foo=bar'类型属性的行)

INPUT=`cat $INPUT_FILE`
while read line; do
   PROP_NAME=`echo $line | cut -f1 -d'='`
   PROP_VALUE=`echo $line | cut -f2- -d'=' | sed 's/\$/\\\$/g`
   time INPUT="$(echo "$INPUT" | sed "s\`${PROP_NAME}\b\`${PROP_VALUE}\`g")"
done <<<$(cat "$PROPERTIES_FILE")
# Do more stuff with INPUT

然而,当我的机器负载很高(超过四十)时,我的 sed 会浪费大量时间

real  0m0.169s
user  0m0.001s
sys  0m0.006s

低负载:

real  0m0.011s
user  0m0.002s
sys  0m0.004s

通常情况下,损失 0.1 秒并不是什么大问题,但属性文件和输入文件都有数百/数千行长,而这 0.1 秒加起来就浪费了一个多小时的时间。

我该怎么做才能解决这个问题?我只需要更多 CPU 吗?

示例属性(行以特殊字符开头,以创建一种方式来指示输入中的某些内容正在尝试访问某个属性)

$foo=bar
$hello=world
^hello=goodbye

示例输入

This is a story about $hello. It starts at a $foo and ends in a park.

Bob said to Sally "^hello, see you soon"

预期结果

This is a story about world. It starts at a bar and ends in a park.

Bob said to Sally "goodbye, see you soon"
linux
  • 7 个回答
  • 255 Views
Martin Hope
Bryan Tan
Asked: 2024-09-05 10:26:47 +0800 CST

为什么创建 StringJoiner 后 jenkins readyaml 停止工作?

  • 5

我创建了以下脚本

import groovy.json.*

pipeline {
    agent { node { label 'mycomputer' } }
    stages {
        stage ( 'Test') {
            steps{
                script {
                    StringJoiner a = new StringJoiner(",");
                    a.add("a").add("b").add("c")
                    env.out = a.toString()
                    echo env.out
                    datas = readYaml file: "/home/cloud-user/test.yaml"
                }
            }
        }
    }
}

输出结果如下:

[管道] { [管道] 阶段 [管道] { (测试) [管道] 脚本 [管道] { [管道] echo a,b,c [管道] readYaml [管道] } [管道] // 脚本 [管道] } [管道] // 阶段 [管道] } [管道] // 节点 [管道] 管道结束发生异常:在字段 com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals 中,在对象 com.cloudbees.groovy.cps.impl.BlockScopeEnv@7bb36fb8 中,在字段 com.cloudbees.groovy.cps.impl.CallEnv.caller 中,在对象 com.cloudbees.groovy.cps.impl.FunctionCallEnv@636cffca 中com.cloudbees.groovy.cps.Continuable.e 在对象 org.jenkinsci.plugins.workflow.cps.SandboxContinuable@2664c301 中的字段 org.jenkinsci.plugins.workflow.cps.CpsThread.program 中 在对象 org.jenkinsci.plugins.workflow.cps.CpsThread@1339b8f9 中的字段 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.threads 中 在对象 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@146a9a96 中的字段 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@146a9a96 中 另外:org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 16a49acb-27b5-4869-b5ae-bfdb1ca5e058 导致:java.io.NotSerializableException:java.util.StringJoiner 在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:278) 在 org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65) 在 org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56) 在 org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50) org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179) at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:341) at java.base/java.util.HashMap.internalWriteEntries(HashMap.java:1858) at java.base/java.util.HashMap.writeObject(HashMap.java:1412) at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:134) at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:231) at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1128) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:271) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1182) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1140) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:271) 在org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1182) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1140) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1119) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:271) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1182) 在 org.jboss.marshalling.river.RiverMarshaller。doWriteSerializableObject(RiverMarshaller.java:1140) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1119) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:271) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1182) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1140) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:271) org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65) 在 org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56) 在 org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50) 在 org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179) 在 java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:341) 在 java.base/java.util.HashMap.internalWriteEntries(HashMap.java:1858) 在java.base/java.util.HashMap.writeObject(HashMap.java:1412) 在 org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:134) 在 org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:231) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1128) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:271) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1182) org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1140) 在 org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:271) 在 org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58) 在 org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:116) 在 org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.lambda$writeObject$1(RiverWriter.java:144) 在org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:331) at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:143) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:580) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:557) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:540) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:464) 在 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:331) 在 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:295) 在 org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:97) 在 java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) 在 hudson.remoting。SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139) 在 jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) 在 jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68) 在 jenkins.util.ErrorLoggingExecutorService.lambda$wrap$0(ErrorLoggingExecutorService.java:51) 在 java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) 在 java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) 在 java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) 在java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) 完成:失败

删除 readyaml 命令会导致错误消失。这对我来说毫无意义,为什么它会尝试在无关的 readyaml 调用中序列化 StringJoiner?

Yaml 内容

---
HELLO: "WORLD"
  • 2 个回答
  • 28 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve