The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to replace a character in the file? ntgobinath Shell Programming and Scripting 2 06-04-2008 12:48 PM
to replace one character by numbers in a file cdfd123 Shell Programming and Scripting 7 10-07-2007 07:25 PM
How to replace a character in a file preethgideon Shell Programming and Scripting 6 08-30-2006 03:19 PM
How would you replace the n character in a file with some xyz? JosephGerard UNIX for Dummies Questions & Answers 2 07-21-2005 05:46 AM
How would I replace the 9th character of every line in a file? LordJezo Shell Programming and Scripting 5 09-01-2004 08:51 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-23-2008
Registered User
 

Join Date: Jul 2008
Posts: 2
Replace nth character in a file with a period

Hi all,

If you look at the example below,I want to replace the 21st character (,) with a period (.). I have 1000 records in a file can someone help me how to do that. Thankyou all in advance.


"2008-07-15 05:35:16,103","Z467813","GET","/LoginDisplayAction.do",,,,"3476.0","/LoginDisplayAction.do"
Reply With Quote
Forum Sponsor
  #2  
Old 07-23-2008
rubin's Avatar
Registered User
 

Join Date: Nov 2007
Posts: 216
Code:
awk '{print substr($0,0,20)"."substr($0,22)}'  log > newlog
Or if only the first comma needs to be replaced use

Code:
sed 's/,/./1' log > newlog
Reply With Quote
  #3  
Old 07-23-2008
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,061
Code:
sed 's/,/./' log > newlog
Reply With Quote
  #4  
Old 07-24-2008
Registered User
 

Join Date: Jul 2008
Posts: 2
Thank you very much, sed command solved my problem. Thank you once again
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0