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-106419

Mithril's questions

Martin Hope
Mithril
Asked: 2018-01-07 01:54:22 +0800 CST

如何使 sed 正则表达式语法像 python 或 javascript 一样工作?[复制]

  • 0
这个问题在这里已经有了答案:
为什么我的正则表达式在 X 中有效,但在 Y 中无效? (1 个回答)
4年前关闭。

我问了一个问题,将字符串插入到文本文件中的列表变量中[使用 sed]

其中@RomanPerekhrest 向我展示了不同的正则表达式语法。

\(=([^)]*\))可以捕获[^)]*为组 1 。这让我很困惑。

您可以在https://regex101.com/r/DRChkE/2上查看结果

在此处输入图像描述 在此处输入图像描述


https://regex101.com/r/LItVNg/1

在此处输入图像描述

这\(([^\)]*)\)在我看来是正确的,但它在 sed 中被破坏了。

所以我想知道如何让 sed 使用正则表达式语法标准作为 python 或 javascript(许多语言的通用标准)。

regular-expression sed
  • 1 个回答
  • 2075 Views
Martin Hope
Mithril
Asked: 2018-01-07 01:09:34 +0800 CST

将字符串插入文本文件中的列表变量 [使用 sed]

  • 1

我想通过脚本添加zsh-autosuggestions插件。~/.zshrc

原文:

plugins=(git)

或者

 plugins=(git
 some1
 some2)

目标 :

plugins=(git
zsh-autosuggestions)
  1. 这行不通。

    sed -i  's/^plugins=\(([^\)]*)\)/plugins=\(\1\nzsh-autosuggestions\n\)/' ~/.zshrc
    

    我很困惑,我认为这([^\)]*) 是第 1 组,但为什么它不起作用

  2. 但删除第一组()

    sed -i  's/^plugins=\([^\)]*\)/plugins=\(\1\nzsh-autosuggestions\n\)/' ~/.zshrc
    

    结果是

    plugins=((git
    zsh-autosuggestions
    )
    )
    

    我已经逃脱了()by \,为什么它变成了第 1 组?

sed text
  • 2 个回答
  • 398 Views
Martin Hope
Mithril
Asked: 2017-11-28 17:24:25 +0800 CST

ssh-copy-id 成功,但还是提示输入密码

  • 6
  1. 我以前ssh-copy-id root@c199成功过。
  2. 我可以在ssh root@c199没有密码提示的情况下登录
  3. 我想由另一个用户自动登录ufo (远程机器有这个用户)
  4. ssh-copy-id ufo@c199 问我输入密码,

    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
    ufo@c199's password:
    
    Number of key(s) added: 1
    
    Now try logging into the machine, with:   "ssh 'ufo@c199'"
    and check to make sure that only the key(s) you wanted were added.
    
  5. 但是通过ssh ufo@c199仍然提示输入密码登录。


我尝试通过 ssh 在 msys2(在 Windows 上)上登录远程 centos,我发现有很多相同的行,例如

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCs7RTfvn83Rxdmvgfh+F4kUlM5FzIUb9rRHaqq11xKIW1gztn/+G4tr+OWl4o6GTW2Z361hIi
ugy8DPtMATN66nTTDUYO0sSvw2BrQfDY4iIENdLpkkHO8KQVGpQE+8tDkaZfD6EQLVtl0uvDE3D77tfcnBLODXgZPQsUSlssMi+pxDbSVjjKgrP
hM1G/L9OTrEHKWDhF+ZBgY1RuLl7ZEdoATbhJaK4FFb9hNn/2CSibVfLts8HJGYQXIQRX/RBzaDZp47sKZvq302ewkkVorNY+c9mmoze6mi8Ip2
zEQOMi6S9zM/yRiD0XZrbmzYfNkoXA03WTmMR/DynVvX2nV /c/Users/xxxx/.ssh/id_rsa

在 centos 中/home/ufo/.ssh/authorized_keys,

我已将 .ssh 用户的文件夹权限更改为 700 并将 authorized_keys 文件更改为 644 。

相同的ssh密钥,无提示ssh root@c199登录,但ssh ufo@c199提示输入密码..


更新

ssh ufo@c199 -vv输出:

....
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:zmCg5vHhBAMd5P4ei82+KsVg072KXbC63C44P0w3zbU
debug1: Host 'c199' is known and matches the ECDSA host key.
debug1: Found key in /c/Users/xxxxx/.ssh/known_hosts:35
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug2: key: /c/Users/xxxxx/.ssh/id_rsa (0x60006bec0), agent
debug2: key: /c/Users/xxxxx/.ssh/id_dsa (0x0)
debug2: key: /c/Users/xxxxx/.ssh/id_ecdsa (0x0)
debug2: key: /c/Users/xxxxx/.ssh/id_ed25519 (0x0)
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/xxxxx/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /c/Users/xxxxx/.ssh/id_dsa
debug1: Trying private key: /c/Users/xxxxx/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/xxxxx/.ssh/id_ed25519
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
ssh password
  • 5 个回答
  • 21278 Views

Sidebar

Stats

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

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve