zozo6015
zozo6015

Reputation: 577

sed comment line number x to y from files

I am having a software which when running ../configure is failing due to some checks.

I have find a way to comment out the lines 49725-49735 manually then I can install the software just fine.

I need to edit the configuration file automatically and comment those lines.

Is there anyone who can give me a hint how to achieve that?

Upvotes: 4

Views: 10372

Answers (3)

shellter
shellter

Reputation: 37288

Not advisable to edit config files like this (fix the error messages), but you know your situation better than I do.

sed '49724,49736 {s/^/#/}' file > newFile && mv newFile file

IHTH

Upvotes: 10

karakfa
karakfa

Reputation: 67507

sed '49725,49735{s/^/##/}' file

replace "##" with your comment code

Upvotes: 3

Avinash Raj
Avinash Raj

Reputation: 174706

You may use awk,

awk 'NR>49724&&NR<49736{$0="#"$0}1' file

Upvotes: 2

Related Questions