Computing.Net > Forums > Unix > sed character replace over a range

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

sed character replace over a range

Reply to Message Icon

Name: Rags
Date: December 23, 2004 at 05:30:30 Pacific
OS: Unix
CPU/Ram: 128
Comment:

Hi

I need a sed command to replace all characters in a text file except those in a
specific range.

i.e

If there is a file with contents:

abcdefghijk

what do i do to replace all characters except
those from 3 to 5 with x

the result must be:
xxcdexxxxxx

Regards
Rags




Sponsored Link
Ads by Google

Response Number 1
Name: cdac1000
Date: December 29, 2004 at 03:29:39 Pacific
Reply:

Try using wildcards with sed.

eg.

/ch0[0-9]*doc/
matches the strings ch01.doc and ch02.doc but not the strings chdoc or changedoc.



0
Reply to Message Icon

Related Posts

See More


Gentoo Linux to FreeBSD December 31, 1969



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: sed character replace over a range

Sed, search/replace w/in range www.computing.net/answers/unix/sed-searchreplace-win-range/7707.html

character replacement using sed/awk www.computing.net/answers/unix/character-replacement-using-sedawk/6473.html

Search string and how to get it replaced www.computing.net/answers/unix/search-string-and-how-to-get-it-replaced/2517.html