Distributions
› Ubuntu
› Fedora
› CentOS
中文资源站
› 网易开源镜像站
1054850490
V2EX  ›  Linux

Linux sed 的命令

  •  
  •   1054850490 · Jun 9, 2022 · 3869 views
    This topic created in 1620 days ago, the information mentioned may be changed or developed.
    如图所示

    假如我的输入为“id”
    jq -r ".id" | sed "s_^_/watch?v=_"
    那么这行代码会输出结果为:/watch?v=id


    那么如何让他输出两个结果?假如我的输入还是 id ,但是一次性打印并替换为两份
    如图下
    5 replies  •  2022-06-09 22:15:29 +08:00
    somicimos
    somicimos
    Jun 9, 2022❤️1
    1
    sed -e "s_^_/watch?v=_p" -e "s_^/watch?v=_/shorts/_"
    1054850490
    1054850490
    OP
    Jun 9, 2022
    2
    @somicimos 谢谢哥,问题完美解决了
    1and0
    1and0
    Jun 9, 2022 via iPhone
    3
    @somicimos 新手问下下划线是啥意思,网上没搜出来
    somicimos
    somicimos
    Jun 9, 2022
    4
    @1and0 分隔符而已,也可以是#等,例如"s#^/watch?v=#/shorts/#"
    1and0
    1and0
    Jun 9, 2022
    5
    @somicimos 谢谢!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   895 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 22:31 · PVG 06:31 · LAX 14:31 · JFK 17:31
    ♥ Do have faith in what you're doing.