Martin L.
Martin L.

Reputation: 1

Bash script - add content to file

I'm new to bash scripting (and Linux at the same time)... but to save some time on building servers at the Office I'm trying to automate some of the configuration through a bash script.

So far I've found what I'm looking for except for that one question... I'm in need to add some text in a specific location in a file. I need to add elevator=noop like in this example:

crashkernel=auto elevator=noop

How can I proceed to do this in a Bash Script under Linux.

Upvotes: 0

Views: 160

Answers (1)

karakfa
karakfa

Reputation: 67567

if you have sed

sed -i.bak 's/crashkernel=auto/& elevator=noop/' file

will save the old file as file.bak and update the input file inplace

Upvotes: 5

Related Questions