Sponsored Content
Top Forums Shell Programming and Scripting Multiple records based on ';' in the record Post 302515272 by ygemici on Tuesday 19th of April 2011 04:33:41 PM
Old 04-19-2011
Code:
# x=$(sed 's/Col/&\n/g' infile|sed -n '/Col$/=' | sed -n '$p')
for ((i = 1 ; i <= $x ; i++ )); do  pr=(${pr[@]} ";p"  ) ; done ; sed -n "$(echo ${pr[@]})" infile
A|B|C|D|E|11||:ColumnA||:ColumnB|G|H
A|B|C|D|E|11||:ColumnA||:ColumnB|G|H

run same cod after results (pr array must zero every run)
Code:
A|B|C|D|E|IIF(:ColumnA = :ColumnC then :ColumnD else :ColumnF)|G|H
A|B|C|D|E|IIF(:ColumnA = :ColumnC then :ColumnD else :ColumnF)|G|H
A|B|C|D|E|IIF(:ColumnA = :ColumnC then :ColumnD else :ColumnF)|G|H
A|B|C|D|E|IIF(:ColumnA = :ColumnC then :ColumnD else :ColumnF)|G|H

regards
ygemici
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Record count based on a keyword in the records

Hi, Am having files with many records, i need to count and display the number of records based on the keyword in one of the column of the records. for e.g THE FILE CONTAINS TWO RECORDS LIKE. 200903031143150 0 1236060795054357lessrv1 BSNLSERVICE1 BSNLSERVICE1 ... (4 Replies)
Discussion started by: aemunathan
4 Replies

2. Shell Programming and Scripting

Parsing record into multiple records in Shell Script

Hi, I am trying to parse a very long record in a text file into multiple records by checking ADD, DELETE, or MODIFY field value in a shell script. Input # File name xyz.txt ADD|N000|8015662|DELETE|N001|9915662|MODIFY|N999|85678 Output ADD|N000|8015662| DELETE|N001|9915662|... (8 Replies)
Discussion started by: naveed
8 Replies

3. Shell Programming and Scripting

Multiple records based on :

Hi , I have the below source source data 1|2|3|:123:abc|4 1|2|a| | 5 1|2|3|4|:a:s:D.....:n|t Target data should be 1|2|3|:123:abc|4 1|2|3|:123:abc|4 1|2|a| | 5 1|2|3|4|:a:s:D.....:n|t 1|2|3|4|:a:s:D.....:n|t 1|2|3|4|:a:s:D.....:n|t 1|2|3|4|:a:s:D.....:n|t (3 Replies)
Discussion started by: mora
3 Replies

4. Shell Programming and Scripting

Split a single record to multiple records & add folder name to each line

Hi Gurus, I need to cut single record in the file(asdf) to multile records based on the number of bytes..(44 characters). So every record will have 44 characters. All the records should be in the same file..to each of these lines I need to add the folder(<date>) name. I have a dir. in which... (20 Replies)
Discussion started by: ram2581
20 Replies

5. UNIX for Dummies Questions & Answers

Split single record to multiple records

Hi Friends, source .... col1,col2,col3 a,b,1;2;3 here colom delimeter is comma(,). here we dont know what is the max length of col3 means now we have 1;2;3 next time i will receive 1;2;3;4;5;etc... required output .............. col1,col2,col3 a,b,1 a,b,2 a,b,3 please give me... (5 Replies)
Discussion started by: bab.galary
5 Replies

6. Shell Programming and Scripting

Splitting record into multiple records by appending values from an input field (AWK)

Hello, For the input file, I am trying to split those records which have multiple values seperated by '|' in the last input field, into multiple records and each record corresponds to the common input fields + one of the value from the last field. I was trying with an example on this forum... (4 Replies)
Discussion started by: imtiaz99
4 Replies

7. Shell Programming and Scripting

Multiple Records from 1 Record

I need to make one record to multiple records based on occurence column in the record and change the date.For example below first record has 5 ,so need to create 5 records from one and change the date to 5 months.Occurence can be any number. I am unable to come with a script.Can some one help ... (5 Replies)
Discussion started by: traininfa
5 Replies

8. Shell Programming and Scripting

Merge records based on multiple columns

Hi, I have a file with 16 columns and out of these 16 columns 14 are key columns, 15 th is order column and 16th column is having information. I need to concate the 16th column based on value of 1-14th column as key in order of 15th column. Here are the example file Input File (multiple... (3 Replies)
Discussion started by: Ravi Agrawal
3 Replies

9. Shell Programming and Scripting

How to split one record to multiple records?

Hi, I have one tab delimited file which is having multiple store_ids in first column seprated by pipe.I want to split the file on the basis of store_id(separating 1st record in to 2 records ). I tried some more options like below with using split,awk etc ,But not able to get proper output. can... (1 Reply)
Discussion started by: jaggy
1 Replies

10. UNIX for Dummies Questions & Answers

Display latest record from file based on multiple columns combination

I have requirement to print latest record from file based on multiple columns combination. EWAPE EW1SLE0000 EW1SOMU01 ABORTED 03/16/2015 100004 03/16/2015 100005 001 EWAPE EW1SLE0000 EW1SOMU01 ABORTED 03/18/2015 140003 03/18/2015 140004 001 EWAPE EW1SLE0000 EW1SOMU01 ABORTED 03/18/2015 220006... (1 Reply)
Discussion started by: tmalik79
1 Replies
tbl-dctrl(1)						   Debian administrator's manual					      tbl-dctrl(1)

NAME
tbl-dctrl - generate tabular representations of data in dctrl format SYNOPSIS
tbl-dctrl [ options ] [ -c column-specification ... ] [ filename ] ... tbl-dctrl --version tbl-dctrl --help DESCRIPTION
tbl-dctrl creates tabular representations of data given to it in Debian control file format. By default, tbl-dctrl reads the whole database, looking for the longest entry in each requested column; it then outputs a table, with bor- ders and column titles, where each column is just wide enough to fit the longest entry. Most of this behaviour can be customized as described below. A column is requested by specifying the -c (--column) switch with a column specification. The simplest kind of a column specification con- sists solely of the name of a field. In such a case, tbl-dctrl will include in the output a column whose title is the literal column spec- ification and whose data is drawn from fields with that name. If no -c options are given, tbl-dctrl will use all fields in the input in the order in which they first appear. There are two optional additions one can make to a column specification. Prefixing the field name with some text followed by an equality sign (for example, -c 'Package name=Package') modifies the column in such a way that the text before the equality sign is used as the col- umn title, while the text after the equality sign is used as the name of the field from which data is drawn. One can also append a colon followed by a positive whole number to the field name. In such a case, the number after the colon specifies the width of the column. These two additions can be used separately or together. If there are more than one colon, the last one is significant. If there are more than one equals sign, the first one is significant. Other colons and equals signs are used simply as data. Note that the whole column specification must be given to tbl-dctrl as one argument, so if it contains spaces, it must be quoted for the shell. If all requested columns have a specified width, tbl-dctrl will produce output immediately, not waiting for the whole input to be read in. OPTIONS
-d delimiter, --delimiter=delimiter Instead of drawing nice borders to the table, use the specified delimiter string to delimit columns in a row. -H, --no-heading Do not print a table heading (column titles). -l level, --errorlevel=level Set log level to level. level is one of fatal, important, informational and debug, but the last may not be available, depending on the compile-time options. These categories are given here in order; every message that is emitted when fatal is in effect, will be emitted in the important error level, and so on. The default is important. -V, --version Print out version information. -C, --copying Print out the copyright license. This produces much output; be sure to redirect or pipe it somewhere (such as your favourite pager). -h, --help Print out a help summary. OPERANDS
tbl-dctrl will read its input from the files named on the command line, in the specified order. A file called - represents the program's standard input stream. If no files are named, the program behaves as if - alone had been named, that is, input is read from the standard input stream. STDIN
The standard input stream may be used as input as specified above in the OPERANDS section. INPUT FILES
All input to tbl-dctrl is in the format of a Debian control file. A Debian control (dctrl) file is a semistructured single-table database stored in a machine-parseable text file. Such a database consists of a set of records; each record is a mapping from field names to field content. Textually, records are separated by empty lines, while each field is encoded as one or more nonempty lines inside a record. A field starts with its name, followed by a colon, followed by the field content. The colon must reside on the first line of the field, and the first line must start with no whitespace. Subsequent lines, in contrast, always start with linear whitespace (one or more space or tab characters). When input is read from multiple files, a record separator is implicit between two adjacent files. ENVIRONMENT VARIABLES
The standard locale environment, specifically its character set setting, affects the interpretation of input and output as character streams. ASYNCHRONOUS EVENTS
Standard UNIX signals have their usual meaning. STDOUT
All output is sent to the standard output stream. The output is a tabular representation of the input database restricted to the specified fields. Logically, the output is a table; when the -d option is used, this table is represented simply by separating columns in each row by the specified delimiter; when the option is not used, a frame is drawn around the table. The order of the columns is the same as the order of the column specifications on the command line. OUTPUT FILES
There are no output files. EXIT STATUS
This utility exits with 0 when successful. It uses a nonzero exit code inconsistently when an error is noticed (this is a bug). CONSEQUENCES OF ERRORS
In case of errors in the input, the output will be partially or completely garbage. In case of errors in invocation, the program will refuse to function. EXAMPLES
The following command line pipe outputs a table of all packages, with their maintainer data, sorted by the maintainer data, that have no content: % grep-available -FInstalled-Size --eq 0 | sort-dctrl -kMaintainer - | tbl-dctrl -cPackage -cMaintainer AUTHOR
The tbl-dctrl program and this manual page were written by Antti-Juhani Kaijanaho. SEE ALSO
apt-cache(1), ara(1), dpkg-awk(1), dpkg-query(1), grep-dctrl(1), sort-dctrl(1), dpkg(8) Debian Project 2006-04-02 tbl-dctrl(1)
All times are GMT -4. The time now is 02:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy