Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a value and incrementing number 1

Status
Not open for further replies.

millap

IS-IT--Management
Jun 13, 2001
70
GB
Hi all,

I'm trying to figure a way to script the generation of a config file, eg;

new connection cpe-1
new connection cpe-2
new connection cpe-3

Is there a way I can do this with awk or sed?

Thanks
millap
 
Hi

To output three lines like in your example do not need to write script :
Code:
[blue]master #[/blue] seq -f "new connection cpe-%g" 3
new connection cpe-1
new connection cpe-2
new connection cpe-3
If this is not what you thought to, then probably you should give us more details.

Feherke.
 
Hi Feherke,

Thanks for the swift response! Thats great, just what I was looking for. Is it also possible to use seq to as do the following in that case:

new connection cpe-1
set nailed-group = 1
new connection cpe-2
set nailed-group = 2
new connection cpe-3
set nailed-group = 3

I should have been a bit more specific.

Cheers
millap

 
Hi

Sorry, I still not understand the reason to fabricate such lines.
Code:
seq 3 | sed 's/\(.*\)/new connection cpe-\1\nset nailed-group = \1/'

[gray]# or[/gray]

awk 'BEGIN{for(i=1;i<=3;i++)print"new connection cpe-"i"\nset nailed-group = "i}'

Feherke.
 
Hi Feherke,

The purpose is to generate profiles for a dslam.

new connection cpe-1
set encapsulation-protocol = atm
set ip-options ip-routing = no
set bridging-options bridge = yes
set bridging-options bridging-group = 451
set bridging-options bridge-type = transparent-bridging
set atm-options vpi = 0
set atm-options vci = 38
set nailed-group = 1
write -f
;

I'm no sed expert but you Sir are! :)

Many thanks for your help it's solved my problem!

millap
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top