Beberapa cara penggunaan sed.
$ cat port.html
8765
nmap example.com
traceroute example.com
echo "finish"
$ cat port.html
8765
nmap example.com
traceroute example.com
echo "finish"
- Menghapus 1 baris sesudah pattern.
sed -i "/8765/{n;d}" port.html
$ cat port.html
8765
traceroute example.com
echo "finish"
- Menghapus 2 baris sesudah pattern.
sed -i "/8765/{n;d;d}" port.html
$ cat port.html
8765
echo "finish"
- Menghapus 3 baris sesudah pattern.
sed -i "/8765/{n;d;d;d}" port.html
$ cat port.html
8765
- Menambahkan baris sesudah pattern
sed -i "/8765.*/a ping example.com" port.html
$ cat port.html
8765
ping example.com
nmap example.com
traceroute example.com
echo "finish"
Komentar
Posting Komentar