Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Merging multiple lines into single line based on one column Post 302987388 by RudiC on Thursday 8th of December 2016 02:25:40 PM
Old 12-08-2016
Try also
Code:
awk -F. -vFMT="'%s'" '$1 != LAST {printf QRS FMT, $1; QRS = ORS; LAST = $1} {printf "," FMT, $2} END {printf ORS}' file
'AAA_POC_DB','TAB1','TAB2','TAB3','TAB4'
'BBB_POC_DB','TAB1','TAB2'
'CCC_POC_DB','TAB6'

These 2 Users Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk multiple lines with 3rd column onto a single line?

I have a H U G E file with over 1million entries in it. Looks something like this: USER0001|DEVICE001|VAR1 USER0001|DEVICE001|VAR2 USER0001|DEVICE001|VAR3 USER0001|DEVICE001|VAR4 USER0001|DEVICE001|VAR5 USER0001|DEVICE001|VAR6 USER0001|DEVICE002|VAR1 USER0001|DEVICE002|VAR2... (4 Replies)
Discussion started by: SoMoney
4 Replies

2. Shell Programming and Scripting

merge lines into single line based on symbol \t

The symbols are \t and \t\t (note: not tab) If the line starts with \t merge them into a single line upto symbol \t\t \t\t to end and start new line I able to join in a single line but not ending at \t\t and I completely confused help would be appreciated:b::D Input \ta tab XXXXXXXXXX \te... (5 Replies)
Discussion started by: repinementer
5 Replies

3. Shell Programming and Scripting

Split single file into multiple files based on the number in the column

Dear All, I would like to split a file of the following format into multiple files based on the number in the 6th column (numbers 1, 2, 3...): ATOM 1 N GLY A 1 -3.198 27.537 -5.958 1.00 0.00 N ATOM 2 CA GLY A 1 -2.199 28.399 -6.617 1.00 0.00 ... (3 Replies)
Discussion started by: tomasl
3 Replies

4. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

5. Shell Programming and Scripting

Awk multiple lines with 4th column on to a single line

This is related to one of my previous post.. I have huge file currently I am using loop to read file and checking each line to build this single record, its taking much much time to parse those records.. I thought there should be a way to do this in awk or sed. I found this code in this forum... (7 Replies)
Discussion started by: Vasan
7 Replies

6. Shell Programming and Scripting

merging multiple lines into single line

Hi, 1. Each message starts with date 2. There is blank line between each message 3. Each message does not contain same number of lines. Any help in merging multiple lines in each message to a single line is much appreciated. AIX: Korn Shell Error log file looks like below. ... (5 Replies)
Discussion started by: bala123
5 Replies

7. UNIX for Dummies Questions & Answers

Merging lines based on one column

Hi, I have a file which I'd like to merge lines based on duplicates in one column while keeping the info for other columns. Let me simplify it by an example: File ESR1 ANASTROZOLE NA FDA_approved ESR1 CISPLATIN NA FDA_approved ESR1 DANAZOL agonist NA ESR1 EXEMESTANE NA FDA_approved... (3 Replies)
Discussion started by: JJ001
3 Replies

8. Shell Programming and Scripting

Returning multiple outputs of a single line based on previous repeated lines

Hello, I am trying to return a time multiple times from a file that has varying output just before the time instance, i.e. cat jumped cat jumped cat jumped time = 1.1 cat jumped cat jumped time = 1.2 cat jumped cat jumped time = 1.3 In this case i would like to output a time.txt... (6 Replies)
Discussion started by: ryddner
6 Replies

9. Shell Programming and Scripting

Merging two tables including multiple ocurrence of column identifiers and unique lines

I would like to merge two tables based on column 1: File 1: 1 today 1 green 2 tomorrow 3 red File 2: 1 a lot 1 sometimes 2 at work 2 at home 2 sometimes 3 new 4 a lot 5 sometimes 6 at work (4 Replies)
Discussion started by: BSP
4 Replies

10. UNIX for Beginners Questions & Answers

Multiple lines to single line

I have code as below # create temporary table `temp4277`(key(waybill_no)) select waybill_no,concat_ws('',card_type,card_series_no) cardinfo from rfid_temp_ticket where waybill_no='4277' group by... (4 Replies)
Discussion started by: kaushik02018
4 Replies
sttyv6(7)						 Miscellaneous Information Manual						 sttyv6(7)

NAME
sttyv6: stty - terminal interface for Version 6/PWB compatibility DESCRIPTION
These routines attempt to map the UNIX Time-Sharing System, Sixth Edition (Version 6), and PWB stty and gtty calls into the current ioctls that perform the same functions. The mapping cannot be perfect. The way the features are translated is described below. The reader should be familiar with before studying this entry. The following data structure is defined in the include file struct sgttyb { char sg_ispeed; /* input speed */ char sg_ospeed; /* output speed */ char sg_erase; /* erase character */ char sg_kill; /* kill character */ int sg_flags; /* mode flags */ } The flags, as defined in sgtty.h, are: define HUPCL define XTABS define LCASE define ECHO define CRMOD define RAW define ODDP define EVENP define ANYP define NLDELAY define TBDELAY define CRDELAY define VTDELAY define BSDELAY define CR0 define CR1 define CR2 define CR3 define NL0 define NL1 define NL2 define NL3 define TAB0 define TAB1 define NOAL define FF0 define FF1 define BS0 define BS1 When the command (ioctl is executed, the flags in the old structure are mapped into their new equivalents in the structure. Then the com- mand is executed. The following table shows the mapping between the old flags and the current flags. Note that flags contained in the structure that are not mentioned below are cleared. HUPCL (if set) sets the termio HUPCL flag; HUPCL (if clear) clears the termio HUPCL flag; XTABS (if set) sets the termio TAB3 flag; XTABS (if clear) clears the termio TAB3 flag; TBDELAY (if set) sets the termio TAB1 flag; TBDELAY (if clear) clears the termio TAB1 flag; LCASE (if set) sets the termio IUCLC, OLCUC, and XCASE flags; LCASE (if clear) clears the termio IUCLC, OLCUC, and XCASE flags; ECHO (if set) sets the termio ECHO flag; ECHO (if clear) clears the termio ECHO flag; NOAL (if set) sets the termio ECHOK flag; NOAL (if clear) clears the termio ECHOK flag; CRMOD (if set) sets the termio ICRNL and ONLCR flags; also, if CR1 is set, the termio CR1 flag is set, and if CR2 is set, the termio ONOCR and CR2 flags are set; CRMOD (if clear) sets the termio ONLRET flag; also, if NL1 is set, the termio CR1 flag is set, and if NL2 is set, the termio CR2 flag is set; RAW (if set) sets the termio CS8 flag, and clears the termio ICRNL and IUCLC flags; also, default values of 6 characters and 0.1 seconds are assigned to MIN and TIME, respectively; RAW (if clear) sets the termio BRKINT, IGNPAR, ISTRIP, IXON, IXANY, OPOST, CS7, PARENB, ICANON, and ISIG flags; also, the default values control-D and null are assigned to the control characters EOF and EOL, respectively; ODDP (if set) if EVENP is also set, clears the termio INPCK flag; otherwise, sets the termio PARODD flag; VTDELAY (if set) sets the termio FFDLY flag; VTDELAY (if clear) clears the termio FFDLY flag; BSDELAY (if set) sets the termio BSDLY flag; BSDELAY (if clear) clears the termio BSDLY flag. In addition, the CREAD bit is set, and, if the baud rate is 110, the CSTOPB bit is set. When using the ispeed entry in the structure is mapped into the appropriate speed in the CBAUD field. The erase and kill entries are mapped into the erase and kill characters. When the (ioctl command is executed, the command is first executed. The resulting structure is then mapped into the structure, which is then returned to the user. The following table shows how the flags are mapped into the old structure. Note that all flags contained in the structure that are not mentioned below are cleared. HUPCL (if set) sets the sgttyb HUPCL flag; HUPCL (if clear) clears the sgttyb HUPCL flag; ICANON (if set) sets the sgttyb RAW flag; ICANON (if clear) clears the sgttyb RAW flag; XCASE (if set) sets the sgttyb LCASE flag; XCASE (if clear) clears the sgttyb LCASE flag; ECHO (if set) sets the sgttyb ECHO flag; ECHO (if clear) clears the sgttyb ECHO flag; ECHOK (if set) sets the sgttyb NOAL flag; ECHOK (if clear) clears the sgttyb NOAL flag; PARODD (if set) sets the sgttyb ODDP flag; PARODD (if clear) clears the sgttyb ODDP flag; INPCK (if set) sets the sgttyb EVENP flag; PARODD, INPCK (if both clear) sets the sgttyb ODDP and EVENP flags; ONLCR (if set) sets the sgttyb CRMOD flag; also, if CR1 is set, the sgttyb CR1 flag is set, and if CR2 is set, the sgttyb CR2 flag is set; ONLCR (if clear) if CR1 is set, the sgttyb NL1 flag is set, and if CR2 is set, the sgttyb NL2 flag is set; TAB3 (if set) sets the sgttyb XTABS flag; TAB3 (if clear) clears the sgttyb XTABS flag; TAB1 (if set) sets the sgttyb TBDELAY flag; TAB1 (if clear) clears the sgttyb TBDELAY flag; FFDLY (if set) sets the sgttyb VTDELAY flag; FFDLY (if clear) clears the sgttyb VTDELAY flag; BSDLY (if set) sets the sgttyb BSDELAY flag; BSDLY (if clear) clears the sgttyb BSDELAY flag. When using the CBAUD field is mapped into the ispeed and ospeed entries of the structure. Also, the erase and kill characters are mapped into the erase and kill entries. Note that, since there is not a one-to-one mapping between the and structures, unexpected results may occur when using the older and calls. Thus, the and calls should be replaced in all future code by the current equivalents, and respectively. WARNINGS
These facilities are included to aid in conversion of old programs, and should not be used in new code. Use the interface described in Note that these conversions do work for programs ported from UNIX Time-Sharing System, Seventh Edition (Version 7), because some V7 flags are defined differently. SEE ALSO
stty(2), termio(7). sttyv6(7)
All times are GMT -4. The time now is 10:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy