PingTool.org

Generate lines in vi editor

When you need to add multiple similar records to a configuration file (IP addresses for example), you may use vi editor to do it directly:

[code] :r! for i in $(seq 1 5); do echo “This is line \#${i}”; done[/code]

This command wil generate 5 lines:
[code]
This is line #1
This is line #2
This is line #3
This is line #4
This is line #5
[/code]

Similar command used to generate Reverse DNS entries in BIND:

[code] :r! for i in $(seq 1 5); do echo “$i PTR host${i}.domain.com”; done[/code]
[code]
1 PTR host1.domain.com
2 PTR host2.domain.com
3 PTR host3.domain.com
4 PTR host4.domain.com
5 PTR host5.domain.com
[/code]

Line numbers can be changed, modifyng the $(seq 1 5); part.

Exit mobile version