The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to change the replace the String in sub folders bobbygsk UNIX for Dummies Questions & Answers 6 09-30-2008 01:09 PM
Find and replace character in a string callimaco0082 UNIX for Dummies Questions & Answers 7 04-10-2008 11:47 AM
replace first character of string sed prkfriryce Shell Programming and Scripting 6 08-03-2007 03:07 PM
find and replace a pattern in a file krishnamaraju Shell Programming and Scripting 1 08-29-2006 11:02 AM
How would you replace the n character in a file with some xyz? JosephGerard UNIX for Dummies Questions & Answers 2 07-21-2005 09:46 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 09-26-2007
mihir0011 mihir0011 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 2
replace character in a string pattern and save the change in same file

I am facing one problem, can any one please suggest me the command for the same in unix. I am using Ksh.

I have a large file with the data that looks like below.

"ROTO2-2007f","_US01","9/15/2007","9/21/2007",346492,"NICK, LCD WATCH"97,1,"NAPOLITJ ","BERGER,M Z & CO INC",0.01,

In this file, if there is a comma in the string enclosed within double quote, then that comma should be replaced with white space. For e.g. as shown above highlighted text, comma after NICK should be replaced with space.

I wrote a command to search for comma within double quote, but I am not able to replace the comma with space in the same file.

The commands I tried are as follow.

awk -F'"' '{print "Line # ", NR, $10}' /usr/users/1shahm/salesiq.dat | grep ","

- This find the string and shows on the screen, it is working fine. But instead of replacing value it is just displaying line and line number on screen.

To replace the value, I tried following commands. But they are not working.

1> awk -F'"' '{tr "," " " }' salesiq.dat |grep ","

2> awk -F'"' '{sed -e "s/\,/ /g"}' salesiq.dat |grep ","

Can you suggest me the appropriate command which I can fit in to replace those commas. Please reply to this mail at your earliest.
 

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0