Sponsored Content
Full Discussion: awk or sed? rows text to co
Top Forums Shell Programming and Scripting awk or sed? rows text to co Post 302950652 by He2 on Monday 27th of July 2015 04:50:39 PM
Old 07-27-2015
awk or sed? rows text to co

Hello Friends!

I would like to help the masters ... I have a file with the entry below and would like a script for that output:

Input file:

Code:
001     1 01-20152142711532-24S       1637909825/05/2015BAHIA SERVICOS                                                               R F,                                        DIST MANDIOCABA     S N                                     PARANAVAI                   8772940076535764032185               04201516/04/201516/03/201515/05/2015 2910/05/201514/04/201505/06/20154402             002.879.563FATPRFD0F.39CA.925E.8CD4.F1AC.6362.3643.EC0B16/04/2015  B                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Responsavel pela manutencao da Iluminacao Publica: Municipio 156                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
002     1 01-20152142711532-24     52877     51879       998   34,41  0301241348  1   220/127  COMERCIAL, SERVICO-TRIFASICO                                                  CONVENCIONAL        kWhANL       998                                 COMERCIAL, SERVICOS, OUTRAS ATIVIDADES  TRIFASICO                                         ATIV FRANQUEADAS E PERMIS CORREIO NAC         0,00
003     1 01-20152142711532-2401042015   99829LIDO      34,41   1157,44                 783,31
003     1 01-20152142711532-2402032015  114531LIDO      36,93   1157,4427/04/2015       778,72
003     1 01-20152142711532-2403022015  122130LIDO      40,70   1157,4425/03/2015       701,80
003     1 01-20152142711532-2404012015  191030LIDO      63,66   1157,4425/02/2015     1.018,46
003     1 01-20152142711532-2405122014  112532MEDIA     35,15   1157,4426/01/2015       593,16
003     1 01-20152142711532-2406112014  134130LIDO      44,70   1157,4423/12/2014       699,15
003     1 01-20152142711532-2407102014  111632MEDIA     34,87   1157,4425/11/2014       588,73
003     1 01-20152142711532-2408092014   87230LIDO      29,06   1157,4427/10/2014       466,03
003     1 01-20152142711532-2409082014  112730MEDIA     37,56   1157,4430/09/2014       647,24
003     1 01-20152142711532-2410072014   83031LIDO      26,77   1157,4429/08/2014       375,12
003     1 01-20152142711532-2411062014   79530LIDO      26,50   1157,4430/07/2014       353,15
003     1 01-20152142711532-2412052014  100532LIDO      31,40   1157,4401/07/2014       439,31
003     1 01-20152142711532-2413042014  129828LIDO      46,35   1157,4430/05/2014       555,43
004     1 01-20152142711532-24PARANAVAI                                  10,29    1,87    7,59    1,00    5,48    1,87                                    1,63    1,00    1,05                O consumidor tem o direito de solicitar apuracoes dos indicadores DIC,FIC,DMIC e DICRI a qualquer tempo.                01/201502/2015                            169,13   20,59   15,19           41,19   30,39
005     1 01-20152142711532-24 1ENERGIA ELET CONSUMO                 998  0,364619       363,89kWh           363,89 29,00%  0,237010TH
005     1 01-20152142711532-24 2ENERGIA ELET USO SISTEMA             998  0,297475       296,88kWh           296,88 29,00%  0,193360TG
005     1 01-20152142711532-24 3ENERGIA CONS. B.VERMELHA                                  84,44kWh            84,44 29,00%          TH
005     1 01-20152142711532-2423Total - Preco (1)                                        745,21
006     1 01-20152142711532-24 1CONT ILUMIN PUBLICA MUNICIPIO                   38,10
006     1 01-20152142711532-2499Total - Outros (2)                              38,10
007     1 01-20152142711532-24ICMS        29,00%       745,21       216,11       R$ 783,31    0,0333
007     1 01-20152142711532-24PIS/PASEP        %       745,20         7,97
007     1 01-20152142711532-24COFINS           %       745,20        36,74
008     1 01-20152142711532-24 1INCLUSO NA FATURA PIS R$7,97 E COFINS R$36,74 CONFORME RES. ANEEL 130/2005.
008     1 01-20152142711532-24 2FATURA AGRUPADA - NAO RECEBER
008     1 01-20152142711532-24 3A qualquer tempo pode ser solicitado o cancelamento de valores não relacionados
008     1 01-20152142711532-24 4à prestação do serviço de energia elétrica, como convênios e doações.
008     1 01-20152142711532-24 5Periodos Band.Tarif.: Vermelha:17/03-14/04
009     1 01-20152142711532-24
010     1 01-20152142711532-24425810              783,31                                                                                                                                                                                                                                        NAO RECEBER - FATURA AGRUPADA
011     1 01-20152142711532-24R F, -S N                                                             PARANAVAI - PR                                                        87729400       011417-211  0301241348         DIST MANDIOCABA                                                                                                                                        UB087366
013     1 01-20152142711532-24     127     117     133     220     202     231
015     1 01-20152142711532-24 1DISTRIBUICAO                                    92,35
015     1 01-20152142711532-24 2ENC. SETORIAIS                                  90,71
015     1 01-20152142711532-24 3ENERGIA                                        291,44
015     1 01-20152142711532-24 4TRANSMISSAO                                      9,89
015     1 01-20152142711532-24 5TRIBUTOS                                       260,82
015     1 01-20152142711532-24 6Soma Demonstrativo                             745,21

output file:

Code:
001     1 01-20152142711532-24S       1637909825/05/2015BAHIA SERVICOS                                                               R F,                                        DIST MANDIOCABA     S N                                     PARANAVAI                   8772940076535764032185               04201516/04/201516/03/201515/05/2015 2910/05/201514/04/201505/06/20154402             002.879.563FATPRFD0F.39CA.925E.8CD4.F1AC.6362.3643.EC0B16/04/2015  B                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Responsavel pela manutencao da Iluminacao Publica: Municipio 156                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
002     1 01-20152142711532-24     52877     51879       998   34,41  0301241348  1   220/127  COMERCIAL, SERVICO-TRIFASICO                                                  CONVENCIONAL        kWhANL       998                                 COMERCIAL, SERVICOS, OUTRAS ATIVIDADES  TRIFASICO                                         ATIV FRANQUEADAS E PERMIS CORREIO NAC         0,00
003     1 01-20152142711532-2401042015   99829LIDO      34,41   1157,44                 783,31 02032015  114531LIDO      36,93   1157,4427/04/2015       778,72 03022015  122130LIDO      40,70   1157,4425/03/2015       701,80 04012015  191030LIDO      63,66   1157,4425/02/2015     1.018,46 05122014  112532MEDIA     35,15   1157,4426/01/2015       593,16 *003     1 01-20152142711532-2406112014  134130LIDO      44,70   1157,4423/12/2014       699,15 *003     1 01-20152142711532-2407102014  111632MEDIA     34,87   1157,4425/11/2014       588,73 08092014   87230LIDO      29,06   1157,4427/10/2014       466,03 09082014  112730MEDIA     37,56   1157,4430/09/2014       647,24 10072014   83031LIDO      26,77   1157,4429/08/2014       375,12 11062014   79530LIDO      26,50   1157,4430/07/2014       353,15 12052014  100532LIDO      31,40   1157,4401/07/2014       439,31 13042014  129828LIDO      46,35   1157,4430/05/2014       555,43
004     1 01-20152142711532-24PARANAVAI                                  10,29    1,87    7,59    1,00    5,48    1,87                                    1,63    1,00    1,05                O consumidor tem o direito de solicitar apuracoes dos indicadores DIC,FIC,DMIC e DICRI a qualquer tempo.                01/201502/2015                            169,13   20,59   15,19           41,19   30,39
005     1 01-20152142711532-24 1ENERGIA ELET CONSUMO                 998  0,364619       363,89kWh           363,89 29,00%  0,237010TH  2ENERGIA ELET USO SISTEMA             998  0,297475       296,88kWh           296,88 29,00%  0,193360TG  3ENERGIA CONS. B.VERMELHA                                  84,44kWh            84,44 29,00%          TH 005     1 01-20152142711532-2423Total - Preco (1)                                        745,21
006     1 01-20152142711532-24 1CONT ILUMIN PUBLICA MUNICIPIO                   38,10 99Total - Outros (2)                              38,10 
007     1 01-20152142711532-24ICMS        29,00%       745,21       216,11       R$ 783,31    0,0333 PIS/PASEP        %       745,20         7,97 COFINS           %       745,20        36,74
008     1 01-20152142711532-24 1INCLUSO NA FATURA PIS R$7,97 E COFINS R$36,74 CONFORME RES. ANEEL 130/2005.  2FATURA AGRUPADA - NAO RECEBER  3A qualquer tempo pode ser solicitado o cancelamento de valores não relacionados  4à prestação do serviço de energia elétrica, como convênios e doações.  5Periodos Band.Tarif.: Vermelha:17/03-14/04
009     1 01-20152142711532-24
010     1 01-20152142711532-24425810              783,31                                                                                                                                                                                                                                        NAO RECEBER - FATURA AGRUPADA
011     1 01-20152142711532-24R F, -S N                                                             PARANAVAI - PR                                                        87729400       011417-211  0301241348         DIST MANDIOCABA                                                                                                                                        UB087366
013     1 01-20152142711532-24     127     117     133     220     202     231
015     1 01-20152142711532-24 1DISTRIBUICAO                                    92,35  2ENC. SETORIAIS                                  90,71  3ENERGIA                                        291,44  4TRANSMISSAO                                      9,89  5TRIBUTOS                                       260,82  6Soma Demonstrativo                             745,21

Tanks,
He2

Last edited by He2; 07-28-2015 at 11:09 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed or awk to convert text files with recurring headings to rows and colum

I have many text file reports generated by a Information Assurance tool that I need to get into a .CSV format or Excel tab delimited format. I want to use sed or awk to grab all the information in the sample text file below and create column headings:Risk ID, Risk Level, Category, Description, How... (5 Replies)
Discussion started by: Bjoeboo
5 Replies

2. Shell Programming and Scripting

Get text between two special rows ?( using awk or sed)?

Hi Friends I am facing some problem in extract the lines between two fixed lines for examplemy text file look like ... -------- line 1 line 2 line 3 --------- line 4 line 5 -------- line 6 line 7 line 8 line 9 line 10 --------- now i want the data between "-------" these... (4 Replies)
Discussion started by: sushantnirwan
4 Replies

3. Shell Programming and Scripting

get text between two special rows ?(awk or sed)?

Hello, I've the follwing text: gfdgfg -------------------------------- dfgfdgdfg fdgfdgfdgdgf fdgf ------------------------------ f g gdgf a constant string that i know --------------------------------------------- data I want to have data I want to have data I want to have data I... (16 Replies)
Discussion started by: eric_
16 Replies

4. AIX

Rows manupulation using AWK or sed

Hi Everyon, I am stuck in a script.I have a file named file1.txt as given below: It contains 2 columns-count and filename. cat file1.txt count filename 100 A_new.txt 1000 A_full.txt 1100 B_new.txt 2000 B_full.txt 1100 C_new.txt 2000 C_full.txt ................... ..................... (10 Replies)
Discussion started by: rajsharma
10 Replies

5. Shell Programming and Scripting

Combining multiple rows in single row based on certain condition using awk or sed

Hi, I'm using AIX(ksh shell). > cat temp.txt "a","b",0 "c",bc",0 "a1","b1",0 "cc","cb",1 "cc","b2",1 "bb","bc",2 I want the output as: "a","b","c","bc","a1","b1" "cc","cb","cc","b2" "bb","bc" I want to combine multiple lines into single line where third column is same. Is... (1 Reply)
Discussion started by: samuelray
1 Replies

6. Shell Programming and Scripting

Using sed (or awk or perl) to delete rows in a file

I have a Unix file with 200,000 records, and need to remove all records from the file that have the character ‘I' in position 68 (68 bytes from the left). I have searched for similar problems and it appears that it would be possible with sed, awk or perl but I do not know enough about any of these... (7 Replies)
Discussion started by: joddo
7 Replies

7. Shell Programming and Scripting

Awk/sed script for transposing any number of rows with header row

Greetings! I have been trying to find out a way to take a CSV file with a large number of rows, and a very large number of columns (in the thousands) and convert the rows to a single column of data, where the first row is a header representing the attribute name and the subsequent series of... (3 Replies)
Discussion started by: tntelle
3 Replies

8. Shell Programming and Scripting

Indexing each repeating pattern of rows in a column using awk/sed

Hello All, I have data like this in a column. 0 1 2 3 0 3 4 5 6 0 1 2 3 etc. where 0 identifies the start of a pattern in my data. So I need the output like below using either awk/sed. 0 1 (2 Replies)
Discussion started by: ks_reddy
2 Replies

9. Shell Programming and Scripting

Text replacement with awk or sed?

Hi guys, I worked for almost a half-day for the replacement of some text automatically with script. But no success. The problem is I have hundred of files, which need to be replaced with some new text. It's a painful work to work manually and it's so easy to do it wrong. For example, I... (2 Replies)
Discussion started by: liuzhencc
2 Replies

10. Shell Programming and Scripting

Format the text using sed or awk

I was able to figure out how to format a text. Raw Data: $ cat test Thu Aug 23 15:43:28 UTC 2018, hostname01, 232.02, 3, 0.00 Thu Aug 23 15:43:35 UTC 2018, hostname02, 231.09, 4, 0.31 Thu Aug 23 15:43:37 UTC 2018, hostname03, 241.67, 4, 0.43 (5 Replies)
Discussion started by: kenshinhimura
5 Replies
All times are GMT -4. The time now is 08:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy