Ubuntu – Replace text of a specific line number using sed

command linesedtext processing

I have a html file users.html that i want to replace the first line. The first line looks like this

<template name="AccountSettings">

I want the first line to read

<template name="Users">

Best Answer

Commands in sed accept an address range. In this case, to limit the replacement to just the first line, the range should be the single address 1 i.e.

sed '1 s/AccountSettings/Users/' users.html