Sponsored Content
Full Discussion: AWK/GREP sorting help
Top Forums Shell Programming and Scripting AWK/GREP sorting help Post 302444175 by zaxxon on Wednesday 11th of August 2010 05:47:12 AM
Old 08-11-2010
You can remove the square brackets in the same awk; added a RS at the end (not sure if needed):
Code:
awk 'BEGIN{ORS=" "}{gsub(/[][]/,"",$4); if(NR==1)print $2,$4;else print $4}END{print RS}' infile
192.168.1.1 AS28513 AS65534 AS5089 AS5089 AS5089 AS5089 AS5089 AS5089 AS174

Edit:
Sorry, just noticed you wanted also to remove duplicates and a sort too.

Last edited by zaxxon; 08-11-2010 at 06:50 AM.. Reason: Didn't read needs properly
This User Gave Thanks to zaxxon For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep sorting/formatting

Hi, I currently have many log files for different webpages inside the folder /log/. The program allows the user to enter a month and then the grep function searches for it, the command i used is below: grep -c "$month" ./log/*.log This works and i can ascertain the number of matches, but I... (10 Replies)
Discussion started by: Jaken
10 Replies

2. Shell Programming and Scripting

awk sorting

Hi, I have used the following code to sort two sets of data: awk '{printf "%10s %s\n",$1,$2}' The first column is text and the second involves numbers. I was just wondering how i would go about sorting the second number so that they ascend from the top? Thanks for any help (4 Replies)
Discussion started by: Jaken
4 Replies

3. Shell Programming and Scripting

sorting in awk

i have following file have following type of data 1~%%~fcashfafh~%%~9797 can i sort(numeric) the file on first field and then on last feild using awk (3 Replies)
Discussion started by: mahabunta
3 Replies

4. Shell Programming and Scripting

Is there any better way for sorting in bash/awk

Hi, I have a file which is:- 1 6 4 8 2 3 2 1 9 3 2 1 3 3 5 6 3 1 4 9 7 8 2 3 I would like to sort from field $2 to field $6 for each of the line to:- 1 2 3 4 6 8 2 1 1 2 3 9 3 1 3 3 5 6 4 2 3 7 8 9 I came across this Arrays on example 26-6. But it is much complicated. I am... (7 Replies)
Discussion started by: ahjiefreak
7 Replies

5. Shell Programming and Scripting

Sorting with sed,awk ...

I need to sort this input using sed, awk or any other tool to give below output Input: RXOCF-8 CLASS 2A 57 RU 40 RXORX-8-0 CLASS 1B 23 45 16 RXORX-8-1 EXTERNAL CLASS 2A (12 Replies)
Discussion started by: aydj
12 Replies

6. Shell Programming and Scripting

Sorting inside awk

I have an array with five columns and i want to write it to a file. Before writing it i must sort it using the field in the fifth column. _________________________________________ |field 1|field 2|field 3|field 4|field 5| | | | | | | | | | |... (6 Replies)
Discussion started by: beatblaster666
6 Replies

7. Shell Programming and Scripting

Sorting a .csv using awk or other

Hello all, I am new here and *relatively* new to Unix. I have a bit of an emergency. I have a three column file that I need to sort: sample name, miRNA, reads per million (RPM) There are multiple samples, and for each sample name there are multiple miRNAs and associated RPMs. Some of these... (6 Replies)
Discussion started by: dunnybocter
6 Replies

8. Shell Programming and Scripting

Sorting within a record using AWK

Hello, I have a file which has the following format: I have to do is sort individual records in the file based on the 4th field. Each record starts with "Module". Is there an easy way to do this using awk. I have tried piping output from awk to sort and also using "sort" inside awk but... (8 Replies)
Discussion started by: fifteate
8 Replies

9. UNIX for Dummies Questions & Answers

GREP for sorting

Hi , I have a file which has a large number of sequences of type: gi_1 AASSKSKSKSSKSKSK.... series_121 DDKFKFKGKGKH gi_3 FFFFLFFLFLFLF series_1 DFFFFFF pattern_3 GEEEEEEEEE gi_2 HKKGGKGKGK series_102 HHHHH pattern_1 (2 Replies)
Discussion started by: siya@
2 Replies

10. Homework & Coursework Questions

Shell Script: Sorting by column using grep/awk

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: You will write a script that will read a tab-separated file that contains the names of all 50 states &... (7 Replies)
Discussion started by: tburns517
7 Replies
pydhcplib.ipv4(3)						     PYDHCPLIB							 pydhcplib.ipv4(3)

NAME
pydhcplib.ipv4 - Type for IP addresses version 4 SYNOPSIS
from pydhcplib.type_ipv4 import ipv4 a = ipv4() a = ipv4(string) a = ipv4(strlist) a = ipv4(int) DESCRIPTION
The class pydhcplib.ipv4 is a type "IP address version 4". It's used for string processing like "192.168.0.4". The class creation argument can be a string like "192.168.0.4". The class creation argument can be a list of bytes like [192,168,0,4]. METHODS
The implemented methods in this class are mostly methods of comparison (= =, >, etc...) else : str() return data converted into a printable string. list() return data converted into a list of bytes. int() return data converted into an 4 bytes int. EXAMPLES
Example program ipv4_example.py : from pydhcplib.type_ipv4 import ipv4 address = ipv4() address1 = ipv4("192.168.0.1") address2 = ipv4("10.0.0.1") address3 = ipv4([192,168,0,1]) print "a0 : ",address print "a1 : ",address1 print "a2 : ",address2 print "a3 : ",address3 if address1 == address2 : print "test 1 : ",address1, "==",address2 else : print "test 1 : " ,address1, "!=",address2 if address1 == address3 : print "test 2 : ", address1, "==",address3 else : print "test 2 : ", address1, "!=",address3 SEE ALSO
pydhcp(8), pydhcplib.hwmac(3), pydhcplib.ipv4(3), pydhcplib.strlist(3), pydhcplib.DhcpPacket(3), pydhcplib.DhcpBasicPacket(3), pydhc- plib.DhcpNetwork(3), pydhcplib.DhcpClient(3), pydhcplib.DhcpRawClient(3), pydhcplib.DhcpDerver(3) BUGS
See http://pydhcplib.tuxfamily.org/ for more information. AUTHOR
Mathieu Ignacio (mignacio[AT]april.org) pydhcplib.ipv4(3)
All times are GMT -4. The time now is 04:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy