简体   繁体   中英

sed command to replace string beginning with spaces and “ssid” but not “scan_ssid”?

I'm trying to replace a string in a config file that may have some extra spaces at the beginning without picking up another line.

network={
  scan_ssid=1
  ssid="My SSID can contain *any* char!"
  psk="6876876868"
  key_mgmt=WPA-PSK
}

The problem is the leading space(s) and the scan_ssid are conflicting any expression I try. I need to match any number of spaces but not any chars.

Everything I've tried changes both ssid and scan_ssid

试试这个简单的sed

sed 's/^[[:blank:]]*ssid=.*/replacement/' data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM