Simple shell script

When I was looking at one of my earlier posts, I noticed that sometimes I do repeat cli commands manually instead of scripting. Life is short! If you can’t find any other shell, junos has also C shell and following is a simple loop which generates several commands following a similar pattern. For example I would like to delete all ethernet-switching families
in one go in an SRX210 device. Then write the following lines into a file named when you are in shell prompt then run it like below;


delete interface fe-0/0/2.0 family ethernet-switching
delete interface fe-0/0/3.0 family ethernet-switching
delete interface fe-0/0/4.0 family ethernet-switching
delete interface fe-0/0/5.0 family ethernet-switching
delete interface fe-0/0/6.0 family ethernet-switching
delete interface fe-0/0/7.0 family ethernet-switching

Then just paste the output under configuration command and commit!


@ x =2
while ($x <= 7)
   echo "delete interface fe-0/0/$x.0 family ethernet-switching "
@ x +=1


About: rtoodtoo

Worked for more than 10 years as a Network/Support Engineer and also interested in Python, Linux, Security and SD-WAN, currently living in the Netherlands and works as a Network Support Engineer. // JNCIE-SEC #223 / RHCE / PCNSE

One thought on “Simple shell script”

  1. Or simply redirect it to “cli” with “configure private” in first and “commit” in last line. 🙂

Leave a Reply to Kaacz Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.