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
Need Help with Perl Scripting Issue. manik112 Shell Programming and Scripting 23 12-13-2008 12:52 PM
Perl Script Issue - Please Help * Thanks!!! jroberson Shell Programming and Scripting 8 11-03-2008 03:47 AM
perl issue .. zedex Shell Programming and Scripting 3 09-13-2008 11:22 PM
issue with if loop in perl amitrajvarma Shell Programming and Scripting 4 01-09-2008 12:02 AM
Perl problem (compiling issue) 01000101 Shell Programming and Scripting 3 05-24-2006 10:15 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #15 (permalink)  
Old 01-29-2009
raj001 raj001 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 13
Hi,

I am amazed !!! It works. You people are really expert. Thanks.

Using the above command, I was able to remove quotes within the field. But I can see that there are some newline/breakline characters within the field, which makes a single line breaks into multiple line.

Is is possible to remove the these character as well?

Once again Thanks You.
  #16 (permalink)  
Old 01-29-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,884
Use
Code:
tr/"\n\r//d
  #17 (permalink)  
Old 01-29-2009
raj001 raj001 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 13
Thanks it is working.

But I am seeing that it is removing the blank field completely, so field values are not matching up with headers. This is happening in both the cases:

(tr/"//d,$_) and (tr/"\n\r//d,$_ )

Previous:
"INTERNAL","Elsey Marilyn R","","CH "," ENTERPRISE"
After:
"INTERNAL","Elsey Marilyn R","CH "," ENTERPRISE"

Is there any way not to remove blank field completely?

I really appreciate your efforts.
  #18 (permalink)  
Old 01-29-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,884
I was confused about something. Use 1 instead of $_ inside grep.
Code:
grep { tr/"\n\r//d,1 }
  #19 (permalink)  
Old 01-29-2009
raj001 raj001 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 13
You are Genius !!! It is working. Thanks.

I hope this is the last question:

What if I dont want to remove the quotes, but add another quotes to quotes, I mean escaping the quotes with quotes.. Something like this:

Previous:
"Internal","1234","HCM","John D","JOHN D","rocks" 12","seigo"

Expected:

"Internal","1234","HCM","John D","JOHN D","rocks"" 12","seigo"

Note: Quotes can occur multiple times within a field.
  #20 (permalink)  
Old 01-29-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,884
Then use s/"/""/g. To still handle the newlines, use both:
Code:
tr/\n\r//d,s/"/""/g,1
inside the grep {}
  #21 (permalink)  
Old 01-29-2009
raj001 raj001 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 13
I tried at first, but it is not working.

Even this is not working:

tr/\n\r//d,s/"/""/g,1
Sponsored Links
Closed Thread

Bookmarks

Tags
perl, perl shift, shift, shift perl

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 05:45 AM.


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