• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

ksh or bash

I want to create a script to add new rules into iptables file on maybe 100 servers. What would be the best way in ksh or bash to do this. If I grep on a certain parameter and then when I find that not sure how to echo"new line 1...."' echo "new line 2" after the matching parameter.
0
lolaferrari
Asked:
lolaferrari
1 Solution
 
liddlerCommented:
I think you need to use sed

for example if you need to text "new line 1" after "parameter1"
you would do:
sed '/parameter1/a new line1' iptable_file >iptable_file.new
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now