FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Sidebar


Top     SiteMap

Manager Server

Target Server

$FHHOME/bin/xxx.sh | xxxx.exp













.

appendix:sed.html



Top#Appendix

How to use sed command in Linux

About sed command




Example

Delete row

$ cat test.txt
123
456
789
abc
def
$ cat test.txt | sed -e "/789/d"
123
456
abc
def


Append row

$ cat test.txt
123
456
abc
def
$ cat test.txt | sed -e "/456/a 789"
123
456
789
abc
def


Insert row

$ cat test.txt
123ab
456ab
abcab
defab
$ cat test.txt | sed -e "/456/i aaa"
123ab
aaa
456ab
abcab
defab


Substitution

$ cat test.txt
123
456
abc
def
$ cat test.txt | sed 's/456/789/g'
123
789
abc
def

$  cat test.txt
Defaults          requiretty
$ cat test.txt |sed 's/Defaults.*requiretty/#Default\trequiretty/g'
#Default        requiretty


Replace if matched

sed -i '/disable/ s/yes/no/' /etc/xinetd.d/tftp"


Reuse

If it is enclosed by \(target character string \), it is partially reused such as \1, \2, \3, … of the replaced character string




appendix

Top#Appendix



appendix/sed.html.txt · Last modified: 2020/02/28 23:14 by kurihara