Sponsored Content
Top Forums Shell Programming and Scripting Print next line beside preceding line on column match Post 303002486 by james2009 on Friday 25th of August 2017 01:15:53 PM
Old 08-25-2017
Print next line beside preceding line on column match

Hi,

I have some data like below:

Code:
John  254
Chris 254
Matt  123
Abe   123
Raj    487
Moh   487

How can i print it using awk to have:

Code:
254 John,Chris
123 Matt,Abe
487 Raj,Moh

Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

match a pattern, print it and the next line

I have a file nbu_faq.txt (Question/answer) which looks like this What I am trying to do is write out each question in a file1.txt and than the question/answer in a file2.txt like this file1.txt Q: What is nbu? Q: What is blablabla...? Q: Why ....? file2.txt Q: What is nbu? A:... (4 Replies)
Discussion started by: nymus7
4 Replies

2. Shell Programming and Scripting

Awk+Grep Input file needs to match a column and print the entire line

I'm having problems since few days ago, and i'm not able to make it works with a simple awk+grep script (or other way to do this). For example, i have a input file1.txt: cat inputfile1.txt 218299910417 1172051195 1172070231 1172073514 1183135117 1183135118 1183135119 1281440202 ... (3 Replies)
Discussion started by: poliver
3 Replies

3. Shell Programming and Scripting

match a pattern and print the line once

Hi, I have a xml file <cisco:name> <cisco:mdNm>Cisco Device 7500 A Series</cisco:mdNm> <cisco:meNm>10.1.100.19</cisco:meNm> <cisco:ehNm>/shelf=1</cisco:ehNm> <cisco:subname> <cisco:meNm>10.1.100.19</cisco:meNm> <cisco:sptp>Cisco PortA Series</cisco:sptp> ... (11 Replies)
Discussion started by: bhagirathi
11 Replies

4. UNIX for Dummies Questions & Answers

MATCH A PATTERN AND PRINT A LINE ABOVE AND BELOW

Dear All, Hv a very specific requirement. I have a very large text file and in which I have to match a pattern and insert a line above and below. Eg: My file cat test date1 date2 date3 date4 I need to match 'date3' and insert "Reminder1" above date3 and insert 'reminder2'... (4 Replies)
Discussion started by: gokulj
4 Replies

5. Shell Programming and Scripting

read file line by line print column wise

I have a .csv file which is seperated with (;) inputfile --------- ZZZZ;AAAA;BBB;CCCC;DDD;EEE; YYYY;BBBB;CCC;DDDD;EEE;FFF; ... ... reading file line by line till end of file. while reading each line output format should be . i need to print only specific columns let say 5th... (2 Replies)
Discussion started by: rocking77
2 Replies

6. Shell Programming and Scripting

Match a line in File 1 with Column in File 2 and print whole line in file 2 when matched

Hi Experts, I am very new to scripting and have a prb since few days and it is urgent to solve so much appreciated if u help me. i have 2 files file1.txt 9647810043118 9647810043126 9647810043155 9647810043161 9647810043166 9647810043185 9647810043200 9647810043203 9647810043250... (22 Replies)
Discussion started by: mustafa.abdulsa
22 Replies

7. Shell Programming and Scripting

Print Line if next line Match a pattern

Hi All, Does anyone know how to print 1H1A....... in peal script print line ^1H1A....... if next line equal 5R0RECEIPT.... Thank for help:D Cat st.txt 1H1A-IN-11-5410-0009420|1010047766|dsds|1|N|IN|IN|000000|1||N|<<<line match 5R0RECEIPT| 5R0RECEIPT|... (2 Replies)
Discussion started by: kittiwas
2 Replies

8. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

9. Shell Programming and Scripting

Input file needs to match a column and print the entire line

I have a file with class c IP addresses that I need to match to a column and print the matching lines of another file. I started playing with grep -if file01.out file02.out but I am stuck as to how to match it to a column and print the matching lines; cat file01.out 10.150.140... (5 Replies)
Discussion started by: lewk
5 Replies

10. UNIX for Beginners Questions & Answers

Compare 1st column from 2 file and if match print line from 1st file and append column 7 from 2nd

hi I have 2 file with more than 10 columns for both 1st file apple,0,0,0...... orange,1,2,3..... mango,2,4,5..... 2nd file apple,2,3,4,5,6,7... orange,2,3,4,5,6,8... watermerlon,2,3,4,5,6,abc... mango,5,6,7,4,6,def.... (1 Reply)
Discussion started by: tententen
1 Replies
edge(8) 							SUPERUSER COMMANDS							   edge(8)

NAME
edge - n2n edge node daemon SYNOPSIS
edge [-d <tun device>] -a <tun IP address> -c <community> -k <encrypt key> -l <supernode host:port> [-p <local port>] [-u <UID>] [-g <GID>] [-f] [-m <MAC address>] [-t] [-r] [-v] DESCRIPTION
N2N is a peer-to-peer VPN system. Edge is the edge node daemon for n2n which creates a TAP interface to expose the n2n virtual LAN. On startup n2n creates the TAP interface and configures it then registers with the supernode so it can begin to find other nodes in the commu- nity. OPTIONS
-d <name> sets the TAP device name as seen in ifconfig. -a <addr> sets the n2n virtual LAN IP address being claimed. This is a private IP address. All IP addresses in an n2n community should belong to the same /24 network (ie. only the last segment of the IP addresses varies). -b cause edge to perform hostname resolution for the supernode address each time the supernode is periodically contacted. -c <community> sets the n2n community name. All edges within the same community look to be on the same LAN (layer 2 network segment). All edges communicating must use the same key and community name. -h write usage to tty then exit. -k <keystring> sets the twofish encryption key from ASCII text (see also N2N_KEY in ENVIRONMENT). All edges communicating must use the same key and community name. -l <addr>:<port> sets the n2n supernode IP address and port to register to. -p <num> binds edge to the given UDP port. Useful for keeping the same external socket across restarts of edge. -u <uid> causes the edge process to drop to the given user ID when privileges are no longer required. -g <gid> causes the edge process to drop to the given group ID when privileges are no longer required. -f causes the edge process to fork and run as a daemon, closing stdin, stdout, stderr and becoming a process group leader. -m <MAC> start the TAP interface with the given MAC address. This is highly recommended as it means the same address will be used if edge stops and restarts. If this is not done, the ARP caches of all peers will be wrong and packets will not flow to this edge until the next ARP refresh. -M <MTU> set the MTU of the edge interface in bytes. MTU is the largest packet fragment size allowed to be moved throught the interface. The default is 1400. -s <netmask> set the netmask of edge interface in IPv4 dotted decimal notation. The default is 255.255.255.0 (ie. /24). -t use HTTP tunneling instead of the normal UDP mechanism (experimental). -r enable packet forwarding/routing through the n2n virtual LAN. Without this option, packets arriving over n2n which are not for the -a <addr> IP address are dropped. -v use verbose logging. ENVIRONMENT
N2N_KEY set the encryption key so it is not visible on the command line EXAMPLES
edge -d n2n0 -c mynetwork -k encryptme -u 99 -g 99 -m DE:AD:BE:EF:01:23 -a 192.168.254.7 -p 50001 -l 123.121.120.119:7654 Start edge with TAP device n2n0 on community "mynetwork" with community supernode at 123.121.120.119 UDP port 7654 and bind the locally used UDP port to 50001. Use "encryptme" as the shared encryption key. Assign MAC address DE:AD:BE:EF:01:23 to the n2n inter- face and drop to user=99 and group=99 after the TAP device is successfull configured. Add the -f option to make edge run as a daemon. Somewhere else setup another edge with similar parameters, eg. edge -d n2n0 -c mynetwork -k encryptme -u 99 -g 99 -m DE:AD:BE:EF:01:21 -a 192.168.254.5 -p 50001 -l 123.121.120.119:7654 Now you can ping from 192.168.254.5 to 192.168.254.7. The MAC address (-m <MAC>) and virtual IP address (-a <addr>) must be different on all edges in the same community. CONFIGURATION
All configuration for edge is from the command line and environment variables. If you wish to reconfigure edge you should kill the process and restart with the desired options. EXIT STATUS
edge is a daemon and any exit is an error. AUTHOR
Luca Deri ( deri (at) ntop.org ), Richard Andrews ( andrews (at) ntop.org ), Don Bindner SEE ALSO
ifconfig(8) supernode(1) tunctl(8) revision 3679 Jan 3, 2009 edge(8)
All times are GMT -4. The time now is 10:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy