Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about SED

Status
Not open for further replies.

BryanY

MIS
Aug 18, 2001
54
US
I'd like to access a file and replace every instance of "TERM=sun" to "TERM=vt100".

Normally i would just use the code
Code:
sed -e 's/TERM=sun/vt100/' file

But unfortunately, larger words also match.

(For example "TERM=sun-color" gets changed to "TERM=vt100-color")

How would i force it so that it only changes an exact match?
 
If it occupies the entire line:
Code:
awk '{sub(/^TERM=sun$/,"TERM=vt100")}1' file
 
or the sed-way:
Code:
sed -e 's/TERM=sun$/TERM=vt100/g' file

Perhaps you find another delimiter (like blank or tab) to be useful:
Code:
sed -e 's/TERM=sun\([ \t]\)/TERM=vt100\1/g' file


seeking a job as java-programmer in Berlin:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top