Page MenuHomeFreeBSD
Authored By
mr.a_lan.ph
May 18 2020, 5:57 AM
Size
911 B
Referenced Files
None
Subscribers
None
Objective: Remove instances of the 'nis' string only from these two lines: 'passwd: files nis sss' and 'group: files nis sss' at /path/to/nsswitch.conf (some other 'nis' strings exist at the 'group: files nis sss' line and elsewhere... so we'll leave them as is and narrow down the hits to the '^passwd' and '^shadow' lines only) and call the string-manipulation command/s via sudo.
Any way to keep the whitespaces or tab stops when I use /usr/bin/ex?
[foo@jumpspeeder ~]$ echo 'passwd: files nis sss' >~/nsswitch.conf
[foo@jumpspeeder ~]$ cat ~/nsswitch.conf
passwd: files nis sss
^
|
|
Look here...
[foo@jumpspeeder ~]$ ex -s -c '%s/^\(passwd:\|shadow:\) \+\(files\) \+nis \+\(sss\)/\1 \2 \3/' -c w -c q ~/nsswitch.conf
[foo@jumpspeeder ~]$ cat ~/nsswitch.conf
passwd: files sss
^
|
|
...here too.
Thanks in advance.

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2579070
Default Alt Text
raw.txt (911 B)

Event Timeline