Linux Bash Script Find Replace Single Line

Posted on 2013-01-20
Last Modified: 2013-01-20
In my bash script I am trying to find and replace a single line in a file:





Any quick way to do this? Sed?
Question by:-TNT-
LVL 77

Expert Comment

ID: 38799795
perl -i.bak -pe 's/server;' /etc/ntp.conf
An ntp.conf.bak will be created if a match/replacement occurs.
LVL 48

Accepted Solution

Tintin earned 500 total points
ID: 38799801
sed -i 's/server' /etc/ntp.conf

Open in new window


Author Closing Comment

ID: 38800023

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iptables limit connection per ip correct way ? 2 93
Ubuntu/Asterisk after upgrade Wav issue 19 54
bad ownership or modes for chroot directory 6 66
How to learn Linux? 10 42
The purpose of this article is to demonstrate how we can use conditional statements using Python.
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now