![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Display Modes | Rate This Thread |
|
|