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



This is an old revision of the document!


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
123
456
abc
def
$ cat test.txt | sed -e "/456/i aaa"
123
aaa
456
abc
def


Substitution

$  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




Top#Appendix



appendix/sed.html.1517501871.txt.gz · Last modified: 2018/02/02 01:17 by kurihara