wiki:linux

Version 2 (modified by yuna, 8 years ago) (diff)

--

リストをCSVに変換

# cat test.txt
aaa
bbb
ccc
ddd

# sed ':loop; N; $!b loop; ;s/\n/,/g' test.txt
aaa,bbb,ccc,ddd

特定文字列が含まれる行を置換

# cat httpd.conf
...
ServerName localhost:80
...

# sed '/^ServerName /c ServerName 192.168.1.1:80'
...
ServerName 192.168.1.1:80
...