The greedy behaviour of a sed substitution command will by default substitute first match occurrence on every line. For example:
$ cat text
bash bash bash
bash bash bash
bash bash bash
$ sed 's/bash/sed/' text
sed bash bash
sed bash bash
sed bash bash
The following linux command will substitute only a first occurrence of string bash to a string sed:
$ sed '0,/bash/s//sed/' text
sed bash bash
bash bash bash
bash bash bash
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: