Using sed to search and replace exact string.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Spork Schivago
    Badcaps Legend
    • Mar 2012
    • 4734
    • United States of America

    #1

    Using sed to search and replace exact string.

    Hi!

    I am attempting to use sed to change a file. The contents are something like this:
    Code:
    #PasswordAuthentication yes
    PasswordAuthentication yes
    I want to change the second PasswordAuthentication to no. However, I am having some issues. My sed command is changing both to no.

    This is what I've tried
    Code:
    sed -i 's/\<PasswordAuthentication yes/PasswordAuthentication no/g' sshd_config
    That changes both.

    Code:
    sed -i "s/\bPasswordAuthentication yes/PasswordAuthentication no/g" sshd_config
    That changes both.

    Code:
    sed -i "s/\>PasswordAuthentication yes/PasswordAuthentication no/g" sshd_config
    That changes neither.

    I guess I'm getting a bit confused about word boundaries. Any ideas what I'm doing wrong and how to accomplish what I'm trying to accomplish?

    Thanks!

    **EDIT: I believe I found the solution.

    Code:
    sed -i "s/^PasswordAuthentication yes*$/PasswordAuthentication no/g" sshd_config
    that seems to change PasswordAuthentication and not #PasswordAuthentication.
    Last edited by Spork Schivago; 10-18-2018, 10:22 AM. Reason: Found the solution!
    -- Law of Expanding Memory: Applications Will Also Expand Until RAM Is Full

Related Topics

Collapse

  • valvashon
    Samsung UN55FH6030CXZA main board USB jack indentification
    by valvashon
    Samsung UN55FH6030CXZA main board, BN41-01894, bad USB jack. Jack is mangled and needs replacing with like. Jack is marked "Simula" with the number 130318. Search for Simula turns up a weak looking website of a company that seems/seemed to supply USB jacks and other USB technology but no current items turn up for sale.

    I should be able to research and find something applicable through a Digi-Key search after I unsolder/cut out this one and measure the mounting/pin connection pattern on the board but I thought I'd ask here to see if anybody knows of an exact make/model...
    01-23-2025, 11:17 AM
  • Tynan Dill
    Vizio e601i-A3 - Has Sound and Display, But No Backlight - Bad Power Supply Board or Bad LED Bulbs ?
    by Tynan Dill
    I was given this TV from my great uncle. He said it just wouldn't turn on one day out of nowhere, replaced the TV, and gave it to me to possibly fix and use for myself.

    Upon bringing it home and plugging it up, it showed a standby light.

    I powered it on and without a flashlight, the display showed the "V" but the lighting is very dim, but visible.

    The screen seems to blackout and stay black, but with a flashlight I can see the display.

    With my Playstation 4 connected via HDMI, and running a game I can hear sound.

    Assuming...
    11-22-2024, 01:46 PM
  • reformatt
    Intel iMacs, 3rd party SSD failures and Fusion setups
    by reformatt
    I thought I'd throw out some of my personal experiences in the last 12 months with Intel iMacs, 2.5" SATA SSD drives and Fusion drive data recoveries.

    As a backgrounder, Apple never fitted a 2.5" SSD's to these iMacs. Apple's SSD option was a system of 32GB NVMe blade drive (NGFF connector) and Seagate 1TB 2.5" HDD, married together in software to become a Fusion drive. Non Fusion systems have just the 1TB Seagate HDD.

    So, the most common reason an iMac comes across my bench is because it's either ridiculously slow, or it fails to boot at all. The most...
    12-18-2024, 10:34 PM
  • SluggerB
    Can't find exact matching caps for replacements, what should I get to prevent video issues?
    by SluggerB
    I have an old Tivo. The Power Supplies are known to have caps that fail. Here are the caps that come with the original power supply:



    I could not find replacement caps with the exact same specs. I followed an online guide and recapped the power supply with caps with these specs



    The power supply now works, however the HDMI video is giving me eye strain. I don't know how a capacitor on a Power supply could impact an HDMI video signal, but it does, the Tivo interface has a flicker now and the color/brightness is off. So I want to get some new caps...
    04-05-2024, 07:47 PM
  • jordanaudio1
    Samsung TV UN60KU6270F power supply
    by jordanaudio1
    Trying to learn electronics repair as a hobby. I have no formal training in electronics, circuits, etc. Everything I know, which isn't much, has been learned from watching youtube videos, reading books, forums, etc. This means, sometimes I have a hard time understanding and interpreting what's important when I look at datasheets, and such.

    My brother has a TV that I'm working on now. He said he was watching it, he heard a loud pop and it went off. I used my DMM to check the fuse, it was blown. From watching lots of hours of electronics repairs on youtube, I figured that was just a...
    07-07-2025, 07:38 PM
  • Loading...
  • No more items.
Working...