Sponsored Content
Top Forums Shell Programming and Scripting KSH or Awk first and last line based on column 2 Post 302699703 by BrownBob on Wednesday 12th of September 2012 07:46:03 AM
Old 09-12-2012
KSH or Awk first and last line based on column 2

Example:

Code:
10.160.101.160,0707073711,22.203.203.200
10.160.101.160,0707075132,22.203.210.249
10.160.101.160,0707085436,22.203.210.249
10.160.101.160,0707091712,22.203.221.176
10.160.101.160,0707091811,22.203.221.176
10.160.101.160,0707091845,22.203.221.176
10.160.101.160,0707092111,22.203.208.18
10.160.101.160,0707094653,22.203.240.84
10.160.101.160,0707094753,22.203.240.84
10.160.101.160,0707094824,22.203.240.84
10.160.101.160,0707101747,22.203.240.84
10.160.101.161,0707104159,22.203.201.19
10.160.101.161,0707141428,22.203.223.22
10.160.101.161,0707141728,22.203.225.28
10.160.101.161,0707155114,22.203.224.14
10.160.101.161,0707155315,22.203.224.14
10.160.101.161,0707155324,22.203.224.14
10.160.101.161,0707161956,22.203.224.14

Expected Output:

Code:
10.160.101.160,0707073711,22.203.203.200
10.160.101.160,0707075132,22.203.210.249
10.160.101.160,0707085436,22.203.210.249
10.160.101.160,0707091712,22.203.221.176
10.160.101.160,0707091845,22.203.221.176
10.160.101.160,0707092111,22.203.208.18
10.160.101.160,0707094653,22.203.240.84
10.160.101.160,0707101747,22.203.240.84
10.160.101.161,0707104159,22.203.201.19
10.160.101.161,0707141728,22.203.225.28
10.160.101.161,0707155114,22.203.224.14
10.160.101.161,0707161956,22.203.224.14

Please help!!!!




It should compare both the private and public IP just the first and the last time record.. if there should be any single record they should be printed as it is....... Please helppppppppppp!!!!
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 09-12-2012 at 08:58 AM.. Reason: code tags, please!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print entire line based on value in a column

Friends, File1.txt abc|0|xyz 123|129|opq def|0|678 890|pqw|sdf How do I print the entire line where second column has value is 0? Expected Result: abc|0|xyz def|0|678 Thanks, Prashant ---------- Post updated at 02:14 PM ---------- Previous update was at 02:06 PM ---------- ... (1 Reply)
Discussion started by: ppat7046
1 Replies

2. Shell Programming and Scripting

How can i delete the duplicates based on one column of a line

I have my data something like this (08/03/2009 22:57:42.414)(:) king aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbb (08/03/2009 22:57:42.416)(:) John cccccccccccc cccccvssssssssss baaaaa (08/03/2009 22:57:42.417)(:) Michael ddddddd tststststtststts (08/03/2009 22:57:42.425)(:) Ravi... (11 Replies)
Discussion started by: rdhanek
11 Replies

3. Shell Programming and Scripting

Reversing a line based on column

Hi, I have a file that looks like this (tab seperated): read - DFHJ read1 - IOPE read2 + AAAB read3 + MMMN Basically what i want to do is reverse column 3 if column 2 has a - but leave it if its + so the output would look like this: read - JHFD read1 - EPOI read2 + AAAB... (3 Replies)
Discussion started by: kylle345
3 Replies

4. Shell Programming and Scripting

ksh: how to extract strings from each line based on a condition

Hi , I'm a newbie.Never worked on Unix before. I want a shell script to perform the following: I want to extract strings from each line ,based on the type of line(Nameline,Subline) and output it to another file.Below is a sample format. 2010-12-21 14:00"1"Nameline"Midterm"First Name:Jane ... (4 Replies)
Discussion started by: angie1234
4 Replies

5. Shell Programming and Scripting

Extract Line and Column from CSV Line in ksh or bash format

Hi, I was doing some research and can't seem to find anything. I'm trying to automate a process by creating a script to read a csv line and column and assigning that value to a variable for the script to process it. Also if you could tell me the line and column if it's on another work ... (3 Replies)
Discussion started by: vpundit
3 Replies

6. Shell Programming and Scripting

KSH or AWK for fetching the first and the last line based on time.

Dears could anybody please help me with the below task as I am a newbie to programming. I have a text file with 4 columns (priv_ip,time,pub_ip). eg: 10.160.101.160,0708044510,22.203.195.151 10.160.101.160,0708044645,22.203.195.151 10.160.101.160,0708050410,22.203.195.151... (5 Replies)
Discussion started by: BrownBob
5 Replies

7. Shell Programming and Scripting

Pick the column value based on another column using awk or CUT

My scenario is that I need to pick value from third column based on fourth column value, if fourth column value is 1 then first value of third column.Third column (2|3|4|6|1) values are cancatenated. Please someone help me to resolve this issue. Source column1 column2 column3 column4... (2 Replies)
Discussion started by: Ganesh L
2 Replies

8. Shell Programming and Scripting

awk to sum a column based on duplicate strings in another column and show split totals

Hi, I have a similar input format- A_1 2 B_0 4 A_1 1 B_2 5 A_4 1 and looking to print in this output format with headers. can you suggest in awk?awk because i am doing some pattern matching from parent file to print column 1 of my input using awk already.Thanks! letter number_of_letters... (5 Replies)
Discussion started by: prashob123
5 Replies

9. UNIX for Dummies Questions & Answers

Extract columns based on the first line of each column

Sorry to bother you guys again. I have a file1 with multiple columns like this:gga_miR_100 gga_miR_300 gga_miR_3500 gga_miR_4600 gga_miR_5600 gga_miR_30 gga_miR_500 kj rwg ghhh jy jyu we vf 5g 5hg h6 56h i8 45t 44r4 4bg 4r546 9lgtr (fer) 4fr f433 3feev f4 bf4 35g vfr ge 2rr ... (5 Replies)
Discussion started by: yuejian
5 Replies

10. UNIX for Beginners Questions & Answers

Awk/sed summation of one column based on some entry in first column

Hi All , I am having an input file as stated below Input file 6 ddk/djhdj/djhdj/Q 10 0.5 dhd/jdjd.djd.nd/QB 01 0.5 hdhd/jd/jd/jdj/Q 10 0.5 512 hd/hdh/gdh/Q 01 0.5 jdjd/jd/ud/j/QB 10 0.5 HD/jsj/djd/Q 01 0.5 71 hdh/jjd/dj/jd/Q 10 0.5 ... (5 Replies)
Discussion started by: kshitij
5 Replies
ripemd(3)							      OpenSSL								 ripemd(3)

NAME
RIPEMD160, RIPEMD160_Init, RIPEMD160_Update, RIPEMD160_Final - RIPEMD-160 hash function SYNOPSIS
#include <openssl/ripemd.h> unsigned char *RIPEMD160(const unsigned char *d, unsigned long n, unsigned char *md); int RIPEMD160_Init(RIPEMD160_CTX *c); int RIPEMD160_Update(RIPEMD_CTX *c, const void *data, unsigned long len); int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); DESCRIPTION
RIPEMD-160 is a cryptographic hash function with a 160 bit output. RIPEMD160() computes the RIPEMD-160 message digest of the n bytes at d and places it in md (which must have space for RIPEMD160_DIGEST_LENGTH == 20 bytes of output). If md is NULL, the digest is placed in a static array. The following functions may be used if the message is not completely stored in memory: RIPEMD160_Init() initializes a RIPEMD160_CTX structure. RIPEMD160_Update() can be called repeatedly with chunks of the message to be hashed (len bytes at data). RIPEMD160_Final() places the message digest in md, which must have space for RIPEMD160_DIGEST_LENGTH == 20 bytes of output, and erases the RIPEMD160_CTX. Applications should use the higher level functions EVP_DigestInit(3) etc. instead of calling the hash functions directly. RETURN VALUES
RIPEMD160() returns a pointer to the hash value. RIPEMD160_Init(), RIPEMD160_Update() and RIPEMD160_Final() return 1 for success, 0 otherwise. CONFORMING TO
ISO/IEC 10118-3 (draft) (??) SEE ALSO
sha(3), hmac(3), EVP_DigestInit(3) HISTORY
RIPEMD160(), RIPEMD160_Init(), RIPEMD160_Update() and RIPEMD160_Final() are available since SSLeay 0.9.0. 50 2013-03-05 ripemd(3)
All times are GMT -4. The time now is 12:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy