Sponsored Content
Top Forums Shell Programming and Scripting How to remove delimiter from specific column? Post 302461729 by Shirisha on Tuesday 12th of October 2010 06:06:57 AM
Old 10-12-2010
Here is the command which i formed working properly. But the problem occurs when My Messages is having colon in it. Only part of message gets displayed (the part after : that only Message3 displayed)

My output looks like:
Code:
,Filename,Error Message,Count

Code:
cat sample.txt | awk -F':|] ' '/ERROR|INFO/{ split($1,fn,"/");
  for (i in fn)
    if(fn[i]~/^snow|^thunder/) {
      ind=i
      strval=fn[ind]
      sub(".*/"strval"/","",$1)
      val=strval","$1
    }
    if (fn[i] !~ /^snow|^thunder/) {
      sub(".*/","",$1)
      OFS=","
      val=strval","$1
    }

    a[val OFS $NF]++
  }
  END{for(j in a)print j,a[j]}'| sort -k1,3

Content of sample.txt
Code:
/mylogsfolderpath/logs/nrf*Log20100930.log/09/30/2010/12:10:04 INFO [UNKNOWN] INFO Message.
/mylogsfolderpath/logs/nrf*220100929.log/09/29/2010/11:35:16 ERROR [12857745252700] Error Message
/mylogsfolderpath/logs/nrf*220100928.log/09/29/2010/11:45:16 ERROR [12857745652700] Error Message1:Message2:Message3

Moderator's Comments:
Mod Comment This code was almost unreadable, so I've reformatted it

Last edited by Scott; 10-12-2010 at 07:28 AM.. Reason: Code tags, formatting
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to remove a string from a specific column in a file

Hello, A basic query. How can I remove a string from a specific column. For example, remove "abcd" just from column 2 in example file: abcd abcd1 abcd abcd2 abcd abcd3 to get output: abcd 1 abcd 2 abcd 3 Thank you!:) (4 Replies)
Discussion started by: auburn
4 Replies

2. Shell Programming and Scripting

rearrange the column names with comma as column delimiter

Hi, I am new to shell scripting, i have requirement can any one help me out in this regrads, in directory i have file like invoice1.txt, invoice2.txt in each file i have fixed number of columns, 62 in number but they are randomly arranged.like for first file invoice1.txt can have columns... (5 Replies)
Discussion started by: madhav62
5 Replies

3. Shell Programming and Scripting

remove special character from a specific column

Hello , i have a text file like this : A123 c12AB c32DD aaaa B123 23DS 12QW bbbb C123 2GR 3RG cccccc i want to remove the numbers from second and third column only. i tried this : perl -pe 's///g' file.txt > newfile.txt but it will remove the number from... (7 Replies)
Discussion started by: shelladdict
7 Replies

4. Shell Programming and Scripting

how to remove tab space only in the column of a specific row

Hi, I need help to remove tab delimited space in the $2 of a specific row. My file is like this:- file1.txt No_1 4 139 156 No_1 5 161 205 No_4 91 227 212 No_19 254 243 263 No_19 645 249 258 No_19 101 2492 2635 No_90 8 277 288... (5 Replies)
Discussion started by: redse171
5 Replies

5. Shell Programming and Scripting

Remove Specific Column in a File using awk

Hi, I would like to ask your expertise to remove specific column no. 8 in the below file using but I don't have an idea on how to simply do this using awk command. Appreciate your help in advance. Input f: ABC 1 1XC CDA 1 2YC CCC 1 3XC AVD 1 3XA Expected output file: ABC 1 1C CDA... (9 Replies)
Discussion started by: zzavilz
9 Replies

6. Shell Programming and Scripting

Overwrite specific column in xml file with the specific column from adjacent line

I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file. Here is the file. <!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
Discussion started by: rk4k
2 Replies

7. Shell Programming and Scripting

Replace specific column delimiter

Hi All, I have a file with a pipe delimiter. I need to replace the delimiter with html tags. I managed to get all the delimiters replaced along with first and last but the requirement is that I need to change 7th delimiter with slight change. File1: ... (2 Replies)
Discussion started by: shash
2 Replies

8. UNIX for Advanced & Expert Users

How to remove the delimiter from the column value within a file?

Hello All, we have some 10 files wherein we are using the ASCII NULL as separator which is nothing but '^@' and we need to change it to pipe delimited file before loading to database. Most of the data seems to be fine but there are instances where this separator tends to appear in the middle of... (9 Replies)
Discussion started by: dJHa
9 Replies

9. Shell Programming and Scripting

Remove lines matching a substring in a specific column

Dear group, I have following input text file: Brit 2016 11 18 12 00 10 1.485,00 EUR Brit 2016 11 18 12 00 10 142,64 EUR Brit 2016 11 18 12 00 10 19,80 EUR Brit 2016 11 18 12 00 10 545,00 EUR Brit 2016 11 18 12 00 10 6.450,00 EUR... (3 Replies)
Discussion started by: gfhsd
3 Replies

10. Shell Programming and Scripting

sed or awk to remove specific column to one range

I need to remove specific column to one range source file 3 1 000123456 2 2 000123569 3 3 000123564 12 000123156 15 000125648 128 000125648 Output required 3 000123456 2 000123569 3 000123564 12 000123156 15 000125648 128 000125648 (6 Replies)
Discussion started by: ranjancom2000
6 Replies
Mail::Message::Convert(3pm)				User Contributed Perl Documentation			       Mail::Message::Convert(3pm)

NAME
Mail::Message::Convert - conversions between message types INHERITANCE
Mail::Message::Convert is a Mail::Reporter Mail::Message::Convert is extended by Mail::Message::Convert::EmailSimple Mail::Message::Convert::Html Mail::Message::Convert::HtmlFormatPS Mail::Message::Convert::HtmlFormatText Mail::Message::Convert::MailInternet Mail::Message::Convert::MimeEntity Mail::Message::Convert::TextAutoformat SYNOPSIS
Available methods are very converter-specific. DESCRIPTION
This class is the base for various message (and message parts) converters. Converters between message objects Internally, the Mail::Message::coerce() is called when foreign objects are used where message objects are expected. That method will automatically create the converting objects, and re-use them. o Mail::Message::Convert::MailInternet Converts the simple Mail::Internet messages into Mail::Message objects. o Mail::Message::Convert::MimeEntity Converts the more complicated MIME::Entity messages into Mail::Message objects. o Mail::Message::Convert::EmailSimple Converts Email::Simple messages into Mail::Message objects. Other converters o Mail::Message::Convert::Html Plays tricks with HTML/XMHTML without help of external modules. o Mail::Message::Convert::HtmlFormatText Converts HTML body objects to plain text objects using the HTML::FormatText module. o Mail::Message::Convert::HtmlFormatPS Converts HTML body objects to Postscript objects using the HTML::FormatPS module. o Mail::Message::Convert::TextAutoformat Converts a text message into text using Text::Autoformat. METHODS
Constructors Mail::Message::Convert->new(OPTIONS) -Option--Defined in --Default fields <see description> log Mail::Reporter 'WARNINGS' trace Mail::Reporter 'WARNINGS' fields => NAMES|ARRAY-OF-NAMES|REGEXS Select the fields of a header which are to be handled. Other fields will not be used. The value of this option is passed to Mail::Message::Head::Complete::grepNames() whenever converters feel a need for header line selection. By default, the "To", "From", "Cc", "Bcc", "Date", "Subject", and their "Resent-" counterparts will be selected. Specify an empty list to get all fields. log => LEVEL trace => LEVEL Converting $obj->selectedFields(HEAD) Returns a list of fields to be included in the format. The list is an ordered selection of the fields in the actual header, and filtered through the information as specified with new(fields). Error handling $obj->AUTOLOAD() See "Error handling" in Mail::Reporter $obj->addReport(OBJECT) See "Error handling" in Mail::Reporter $obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) Mail::Message::Convert->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) See "Error handling" in Mail::Reporter $obj->errors() See "Error handling" in Mail::Reporter $obj->log([LEVEL [,STRINGS]]) Mail::Message::Convert->log([LEVEL [,STRINGS]]) See "Error handling" in Mail::Reporter $obj->logPriority(LEVEL) Mail::Message::Convert->logPriority(LEVEL) See "Error handling" in Mail::Reporter $obj->logSettings() See "Error handling" in Mail::Reporter $obj->notImplemented() See "Error handling" in Mail::Reporter $obj->report([LEVEL]) See "Error handling" in Mail::Reporter $obj->reportAll([LEVEL]) See "Error handling" in Mail::Reporter $obj->trace([LEVEL]) See "Error handling" in Mail::Reporter $obj->warnings() See "Error handling" in Mail::Reporter Cleanup $obj->DESTROY() See "Cleanup" in Mail::Reporter $obj->inGlobalDestruction() See "Cleanup" in Mail::Reporter DIAGNOSTICS
Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. SEE ALSO
This module is part of Mail-Box distribution version 2.105, built on May 07, 2012. Website: http://perl.overmeer.net/mailbox/ LICENSE
Copyrights 2001-2012 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.14.2 2012-05-07 Mail::Message::Convert(3pm)
All times are GMT -4. The time now is 01:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy