![]() |
|
|
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 |
| Changing one column of delimited file column to fixed width column | manneni prakash | Shell Programming and Scripting | 5 | 06-22-2009 06:27 AM |
| Grep strings from file and put in Column | thepurple | Shell Programming and Scripting | 2 | 12-08-2008 03:50 AM |
| Deleting column from a flatfile with delimiter | rsprabha | Shell Programming and Scripting | 5 | 10-03-2008 05:18 AM |
| Delete repeated nos in a file | gini | UNIX for Dummies Questions & Answers | 2 | 09-02-2008 04:07 PM |
| Get rid of repeated entries. | jijibabawu | Shell Programming and Scripting | 2 | 10-03-2005 11:17 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Deleting repeated strings in column 2
Hi to all, I have a file where the subject could contain "Summarized Availability Report" or only "Summarized Report" If the subject is "Summarized Availability Report" I want to apply it Scrip1 and if the subject is "Summarized Report" I want to apply it Scrip2. 1-) I would like you help me how to choose Script1 if Subject contains "Summarized Availability Report". 2-) To develop part of this Script1. The Inputfile in $2 has strings with 2 or 3 between "_M" and "X-Z". Code:
Inputfile example when Subject contain the string "Availability": Subject: Summarized Availability Report Comment GHH_M55X May 21 2009 4:45PM Comment GHH_M55Y May 21 2009 4:45PM Comment GHH_M55Z May 21 2009 4:45PM Comment YUP_M19Y May 18 2009 7:45PM Comment YUP_M19Y May 18 2009 7:45PM Comment WON_M123X May 17 2009 11:22AM Comment CET_M123X May 15 2009 9:12AM Desired output: (Script1_part 1: After line containing "Subject:...", delete last letter of strings in $2) (With my knowledge I got this Code:
awk -F"[X-Z] " '/M[0-9][0-9]|[0-9][X-Z]/ {print $1" "$2}')
Code:
Subject: Summarized Report Comment GHH_M55 May 21 2009 4:45PM Comment GHH_M55 May 21 2009 4:45PM Comment GHH_M55 May 21 2009 4:45PM Comment YUP_M19 May 18 2009 7:45PM Comment YUP_M19 May 18 2009 7:45PM Comment WON_M123 May 17 2009 11:22AM Comment CET_M123 May 15 2009 9:12AM (Scrip1_part 2: After line containing "Subject:...", delete lines with repeated elements in $2) (In this part I need help, I don´t know how to eliminate repeated strings in column 2 ) Code:
Subject: Summarized Report Comment GHH_M55 May 21 2009 4:45PM Comment YUP_M19 May 18 2009 7:45PM Comment WON_M123 May 17 2009 11:22AM Comment CET_M123 May 15 2009 9:12AM (Script1_part 3: After line containing "Subject:...", delete $1 and join lines with their Subject line) Code:
Last lasta result Subject: Summarized Report->GHH_M55 May 21 2009 4:45PM, YUP_M19 May 18 2009 7:45PM, WON_M123 May 17 2009 11:22AM, CET_M123 May 15 2009 9:12AM Thanks in advance for any help |
|
||||
|
Hey guys, thanks for your help. I tested both solutions, but I would like to do a mix between them. For panyam solution I get unique lines but not joined like Code:
Subject: Summarized Report->GHH_M55 May 21 2009 4:45PM, YUP_M19 May 18 2009 7:45PM, WON_M123 May 17 2009 11:22AM, CET_M123 May 15 2009 9:12AM and for devtakh solution I get the solution like a joined sentence, but including repeated items. I replace in your code the part Code:
a[$2]=$2" "$3... to Code:
a[$2]=substr($2,1,length($2)-1)" "$3... But from here I´m not sure how to present uniques lines in a joined sentence. One more thing: Assuming I have 2 scripts how to choose Script1 if "Subject" contains "Summarized Availability Report" within? Thanks again, Best regards |
|
||||
|
Code:
But from here I´m not sure how to present uniques lines in a joined sentence. use Code:
"uniq -ud" to get a single copy of the repeated lines. Assuming I have 2 scripts how to choose Script1 if "Subject" contains "Summarized Availability Report" within? that can be done by conditional checking. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|