Sponsored Content
Top Forums Shell Programming and Scripting Awk: How to merge duplicate lines and print in a single Post 302504403 by winter9 on Monday 14th of March 2011 01:35:14 PM
Old 03-14-2011
Awk: How to merge duplicate lines and print in a single

The input file:
Code:
>cat module1
200611051053                     95
200523457498                     35
200617890187                     57
200726098123                     66
200645676712                     71
200744556590                     68

>cat module2
200645676712                     56
200617890187                     50
200523457498                     29
200726098123                     62
200744556590                     69
200611051053                     90

expecting output
Code:
Reg No                      module1       module2
200611051053                     95        90
200523457498                     35        29
200617890187                     57        50
200726098123                     66        62
200645676712                     71        56
200744556590                     68        69

Many Thanks

Last edited by Scott; 03-14-2011 at 03:00 PM.. Reason: Less formatting, more code tags, please...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merge multi-lines into one single line

Hi, Can anyone help me for merge the following multi-line log which beginning with a number and time: into one line. For each line need to delete the return and add a space. Please see the red color line. *****Original Log*****... (4 Replies)
Discussion started by: happyday
4 Replies

2. Shell Programming and Scripting

Help on Merge multi-lines into one single line

Hello, Can anyone let me know how to use Perl script to Merge following multi-lines into one single line... ***** Multi-line***** FILE_Write root OK Tue Jul 01 00:00:00 2008 cl_get_path file descriptor = 1 FILE_Write root OK ... (5 Replies)
Discussion started by: happyday
5 Replies

3. 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

4. Shell Programming and Scripting

Print duplicate only lines as normal output - Awk

input output a1 100 200 XYZ_X a1 98 188 ABC (2 Replies)
Discussion started by: quincyjones
2 Replies

5. UNIX for Advanced & Expert Users

Merge a group of lines into single line

Hi Everybody, Below are the contents of the a text file .., SN = 8 MSI = 405027002277133 IKVALUE = DE6AA6A11D42B69DF6398D44B17BC6F2 K4SNO = 2 CARDTYPE = SIM ALG = COMP128_3 SN = 8 MSI = 405027002546734 IKVALUE = 1D9F8BAA73973D8FBF8CBFB01436D822 K4SNO = 2 CARDTYPE = SIM ALG =... (8 Replies)
Discussion started by: prasanth_babu
8 Replies

6. Shell Programming and Scripting

Print duplicate lines

I have a file where some of the lines are duplicates. How do I use bash to print all the lines that have duplicates? (2 Replies)
Discussion started by: locoroco
2 Replies

7. UNIX for Dummies Questions & Answers

Need help combining txt files w/ multiple lines into csv single cell - also need data merge

:confused:Hello -- i just joined the forums. I am a complete noob -- only about 1 week into learning how to program anything... and starting with linux. I am working in Linux terminal. I have a folder with a bunch of txt files. Each file has several lines of html code. I want to combine... (2 Replies)
Discussion started by: jetsetter
2 Replies

8. UNIX for Dummies Questions & Answers

[Solved] How to extract single and duplicate lines from file?

Hi, I need help! I have two files, one containing a list of codes and the other a list of codes and their meaning. I need to extract from file 2 all the codes from file 1 into a new file. These are my files: File1: Metbo Metbo Memar Mth Metbo File2: Metbo Methanoculleus... (3 Replies)
Discussion started by: Lokaps
3 Replies

9. Shell Programming and Scripting

Merge multiple lines into a single line

Hi all, I'm relatively new to scripting, I can do pretty basic things. I have a daily log file that looks like: timestamp=2017-06-28-01.01.35.080576; event status=0; userid=user1; authid=user1; application id=10.10.10.10.11111.12345678901; application name=GUI; ... (29 Replies)
Discussion started by: dwdnet
29 Replies

10. UNIX for Beginners Questions & Answers

Merge multi-lines into one single line using shell script or Linux command

Hi, Can anyone help me for merge the following multi-line log which beginning with a " and line ending with ": into one line. *****Original Log***** 087;2008-12-06;084403;"mc;;SYHLR6AP1D\LNZW;AD-703;1;12475;SYHLR6AP1B;1.1.1.1;0000000062;HGPDI:MSISDN=12345678,APNID=1,EQOSID=365;... (3 Replies)
Discussion started by: rajeshlinux2010
3 Replies
strchg(1M)																strchg(1M)

NAME
strchg, strconf - change or query stream configuration SYNOPSIS
module2]... [ module] file DESCRIPTION
The and commands are used to change or query the configuration of the stream associated with the user's standard input. The command pushes modules on and/or pops modules off the stream. The command queries the configuration of the stream. Only the superuser or owner of a STREAMS device may alter the configuration of that stream. strchg Options The command uses the following options: pushes modules onto a stream. The modules are pushable STREAMS modules as defined by module1, module2, and so on. The modules are pushed in order. That is, module1 is pushed first, module2 is pushed second, etc. With the option alone, pops the topmost module from the stream. With the and options, all the modules above the topmost driver are popped. With the and module options, all modules above but not including module are popped off the stream. The and options are mutually exclusive. The user can specify a file that contains a list of modules representing the desired configuration of the stream. Each module name must appear on a separate line where the first name represents the topmost module and the last name represents the module that should be closest to the driver. The command will determine the current configuration of the stream and pop and push the necessary modules in order to end up with the desired configuration. The and options are mutually exclusive. strconf Options Invoked without any arguments, prints a list of all the modules in the stream as well as the topmost driver. The list is printed in one name per line where the first name printed is the topmost module on the stream (if one exists) and the last item printed is the name of the driver. The command uses the following options: Only the topmost module (if one exists) is printed. checks if the named module is present on the stream. If so, prints the message, and returns zero. If not, prints the message, and returns a non-zero value. The and options are mutually exclusive. Notes If the user is neither the owner of the stream nor the superuser, the command will fail. If the user does not have read permissions on the stream and is not the superuser, the command will fail. If modules are pushed in the wrong order, one could end up with a stream that does not function as expected. For ttys, if the line disci- pline module is not pushed in the correct place, one could have a terminal that does not respond to any commands. DIAGNOSTICS
returns zero on success. It prints an error message and returns non-zero status for various error conditions, including usage error, bad module name, too many modules to push, failure of an on the stream, or failure to open file from the option. returns zero on success (for the or option, "success" means the named or topmost module is present). It returns a non-zero status if invoked with the or option and the module is not present. It prints an error message and returns non-zero status for various error condi- tions, including usage error or failure of an on the stream. EXAMPLES
The following command pushes the module on the stream associated with the user's standard input: The following command pops the topmost module from the stream associated with The user must be the owner of this device or be superuser. If the file, contains the following: then the command will configure the user's standard input stream so that the module is pushed over the driver, followed by and closest to the stream head. The command with no arguments lists the modules and topmost driver on the stream. For a stream that only has the module pushed above the ports driver, it would produce the following output: The following command asks if is on the stream: and produces the following output while returning an exit status of 0: FILES
NLS catalogs NLS catalogs SEE ALSO
streamio(7). strchg(1M)
All times are GMT -4. The time now is 04:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy