Sponsored Content
Top Forums Shell Programming and Scripting How to remove unwanted " from string... Post 302537341 by agama on Thursday 7th of July 2011 11:19:30 PM
Old 07-08-2011
This worked on the small test I ran:

Code:
sed 's/^"/~/; s/"$/~/; s/",/~,/g; s/,"/,~/g; s/"//g; s/~/"/g' in-file >out-file

It assumes that quotes to be kept are at the beginning/ending of the line, or are either preceded or trailed by a comma. It will not handle the case where something like 3" in the text is followed by a comma:

Code:
"204312","ARMAFLEX-1 3/8 X 3", NAT COLOUR",,"2.48","","PER FOOT","N"

If you have cases like this, then you'll need something a bit more robust.

Oh yea, it assumes no tildas (~) in the input!

Last edited by agama; 07-08-2011 at 12:21 AM.. Reason: clarification
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove unwanted data?

Hi Can any one help me remove the unwanted data? I would want to remove the complete event id 4910 ( the type there is INFO), that means, I have to remove starting from 7th - 19th lines. can any one of you please help? Thanks, (24 Replies)
Discussion started by: hitmansilentass
24 Replies

2. Shell Programming and Scripting

Remove unwanted XML Tags

I have set of sources and the respective resolution. Please advice how to resolve the same using Unix shell scripting. Source 1: ======= <ext:ContactInfo xmlns:ext="urn:AOL.FLOWS.Extensions"> <ext:InternetEmailAddress>AOL@AOL.COM</ext:InternetEmailAddress> </ext:ContactInfo> Resoultion... (1 Reply)
Discussion started by: ambals123
1 Replies

3. Solaris

Remove unwanted packages

I got a system which was installed with SUNWCXall cluster installed on it and i want remove unwanted software like GMNOME, Java Desktop System, Staroffice and numerous other softwares .. i want to do an automated removal of these packages where its uninstalled by itself ..from the is there any... (4 Replies)
Discussion started by: fugitive
4 Replies

4. Shell Programming and Scripting

Remove "/" from a string

Hi, I've a string "200910/22-101010" ( this is date and time string YYYYMMDD/HHMMSS format) , how can i remove "/" and assign it to a new variable a value of 20091022 only thanks (6 Replies)
Discussion started by: rudoraj
6 Replies

5. Emergency UNIX and Linux Support

Remove Unwanted Libraries - optimizing

We have a huge makefile composing of inclusion of libraries, objects and system libraries to generate a binary. How do we find out that which of the libraries we can remove in the most efficient way? Doing hit and trial method is a waste of time and can during the linking with some post linking... (12 Replies)
Discussion started by: uunniixx
12 Replies

6. Shell Programming and Scripting

Remove unwanted lines

I have a .xml file, where i need some output. The xml file is like: Code: <?******?></ddddd><sssss>234</dfdffsdf><sdhjh>534</dfdfa>......... /Code I need the output like: code 234 534 . . . /code How can i do it? (5 Replies)
Discussion started by: anupdas
5 Replies

7. Shell Programming and Scripting

Remove path string from file (string contains "/")

This is the way sed -i 's/home/$USER/.config/hello_there//g' /home/$USER/.gnomerc But, as far as I saw you cannot add any "/" in the string you want to remove.... So, what should I do in order to remove this path (which contains "/") ?:confused: (7 Replies)
Discussion started by: hakermania
7 Replies

8. Shell Programming and Scripting

How to remove unwanted strings?

Hi Guys, Can someone give me a hand on how I can remove unwanted strings like "<Number>" and "</Number>" and retain only the numbers from the input file below. INPUT FILE: <Number>10050000</Number> <Number>1001340001</Number> <Number>1001750002</Number> <Number>100750003</Number>... (8 Replies)
Discussion started by: pinpe
8 Replies

9. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

10. Shell Programming and Scripting

Remove leading "#" from a String

Hi Everyone, i am new to scripting and stuck in something. Query is : I have a properties file eg. data.properties. This data.properties have some values example : key1=value1 key2=value2 #key3=value3 as key3 is commented by #. so i want to write a script , that will remove # from... (3 Replies)
Discussion started by: Raj87ng
3 Replies
Paranoid::Log::File(3pm)				User Contributed Perl Documentation				  Paranoid::Log::File(3pm)

NAME
Paranoid::Log::File - File Logging Functions VERSION
$Id: File.pm,v 0.83 2010/04/15 23:23:28 acorliss Exp $ SYNOPSIS
use Paranoid::Log; enableFacility('events', 'file', 'debug', '+', $filename); DESCRIPTION
This module logs messages to the log files, and is safe for use with forked children logging to the same files. Each child will open their own filehandles and use advisory locking for writes. This module should not be used directly, Paranoid::Log should be your exclusive interface for logging. SUBROUTINES
/METHODS NOTE: Given that this module is not intended to be used directly nothing is exported. init log remove dump DEPENDENCIES
o Fcntl o Paranoid::Debug o Paranoid::Filesystem o Paranoid::Input SEE ALSO
o Paranoid::Log BUGS AND LIMITATIONS
This isn't a high performance module when dealing with a high logging rate with high concurrency. This is due to the advisory locking requirement and the seeks to the end of the file with every message. This facility is intended as a kind of lowest-common demoninator for programs that need some kind of logging capability. AUTHOR
Arthur Corliss (corliss@digitalmages.com) LICENSE AND COPYRIGHT
This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information. (c) 2005, Arthur Corliss (corliss@digitalmages.com) perl v5.14.2 2010-04-15 Paranoid::Log::File(3pm)
All times are GMT -4. The time now is 02:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy