UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 16th, 2005, 12:00 PM
puma puma is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 1 puma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 28 sec
Reputation Power: 0
Help with sed

Hi there

I need help building a scrip that change a character in a spesific position in the line

what I am looking is replace 10 for 20 that are located in the position 321:322 and the record lenth is 497

can some one help

Thanks Puma

Reply With Quote
  #2  
Old June 19th, 2005, 09:11 PM
fpmurphy fpmurphy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: USA
Posts: 289 fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 3 h 22 m 4 sec
Reputation Power: 6
sed is line/pattern orientated not line/column orientated.
Suggest you use PERL or AWK instead.

Reply With Quote
  #3  
Old June 23rd, 2005, 03:24 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,098 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 Days 9 h 5 m 46 sec
Reputation Power: 9
sed can more

Quote:
Originally Posted by puma
Hi there

I need help building a scrip that change a character in a spesific position in the line

what I am looking is replace 10 for 20 that are located in the position 321:322 and the record lenth is 497

can some one help

Thanks Puma


this is what you are seeking for


s/\(.\{5\}\)\(..\)\(.*\)/\1XX\3/g

s = substitute
\( = start saving data in buffer1
. = any char
\{5\} = repeated 5 times
\) = end saved buffer1
\(..\) = save next 2 chars in buffer2
\(.*\) = save rest of line in buffer3
\1 = print buffer1
XX = insert XX after buffer1 = replace buffer2
\3 = print buffer3
__________________
working on Solaris[5-9], preferred languages french and C.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Help with sed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT