Sponsored Content
Full Discussion: Help around sort
Top Forums Shell Programming and Scripting Help around sort Post 302437807 by rdcwayx on Friday 16th of July 2010 06:47:57 AM
Old 07-16-2010
radoulov's code can't remove duplicate records.

Code:
$ cat logfile
10.1.2.3 - uid=jroux,ou=people,dc=univ-myuniv,dc=fr [12/Jul/2010:15:03:14 +0200] "GET /anURL" Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"
10.1.2.3 - uid=jroux,ou=people,dc=univ-myuniv,dc=fr [12/Jul/2010:15:03:14 +0200] "GET /anURL" Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"
10.2.3.4 - uid=arousseau,ou=people,dc=univ-myuniv,dc=fr [12/Jul/2010:15:34:11 +0200] "GET /anURL" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"
10.4.3.4 - uid=arousseau,ou=people,dc=univ-myuniv,dc=fr [12/Jul/2010:15:34:11 +0200] "GET /anURL" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"
10.4.3.4 - uid=arousseau,ou=people,dc=univ-myuniv,dc=fr [12/Jul/2010:15:34:11 +0200] "GET /anURL" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"
10.5.3.4 - uid=arousseau,ou=people,dc=univ-myuniv,dc=fr [12/Jul/2010:15:34:11 +0200] "GET /anURL" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"
10.4.3.4 - uid=arousseau,ou=people,dc=univ-myuniv,dc=fr [12/Jul/2010:15:34:11 +0200] "GET /anURL" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"

Code:
$ awk 'END {
   for (U in uid) printf "%s\n%s\n\n", U, uid[U]
   }
 { uid[$3] = uid[$3] ? uid[$3] RS $1 : $1 }
   ' logfile

uid=arousseau,ou=people,dc=univ-myuniv,dc=fr
10.2.3.4
10.4.3.4
10.4.3.4
10.5.3.4
10.4.3.4

uid=jroux,ou=people,dc=univ-myuniv,dc=fr
10.1.2.3
10.1.2.3

Try mine:
Code:
 awk '!a[$1 FS $3] {b[$3]=b[$3] FS $1;a[$1 FS $3]=1} 
      END {for (i in b) {print i;split(b[i],s," "); for (j in s) print s[j]}}' logfile


uid=arousseau,ou=people,dc=univ-myuniv,dc=fr
10.2.3.4
10.4.3.4
10.5.3.4
uid=jroux,ou=people,dc=univ-myuniv,dc=fr
10.1.2.3

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sort

I check the man page but I still cannot see what this command is supposed to do sort +5 -6 <file> It just seems to sort the file as normal?? Thanks Calypso (3 Replies)
Discussion started by: Calypso
3 Replies

2. Shell Programming and Scripting

How to Sort Floating Numbers Using the Sort Command?

Hi to all. I'm trying to sort this with the Unix command sort. user1:12345678:3.5:2.5:8:1:2:3 user2:12345679:4.5:3.5:8:1:3:2 user3:12345687:5.5:2.5:6:1:3:2 user4:12345670:5.5:2.5:5:3:2:1 user5:12345671:2.5:5.5:7:2:3:1 I need to get this: user3:12345687:5.5:2.5:6:1:3:2... (7 Replies)
Discussion started by: daniel.gbaena
7 Replies

3. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

4. Shell Programming and Scripting

Is it Possible to sort a list of hexadecimal numbers using "sort" command?

Hello Everybody :) !!!. i have question in mind, is it possible to sort a list of hexadecimal numbers using "sort" command? (9 Replies)
Discussion started by: Kesavan
9 Replies

5. Shell Programming and Scripting

Help to sort out... Possible use of sort command

I have an input like 4.3.6.66 4.3.6.67 4.3.6.70 4.3.6.25 4.3.6.15 4.3.6.54 4.3.6.44 4.3.6.34 4.3.6.24 4.3.6.14 4.3.6.53 4.3.6.43 4.3.6.49 4.3.6.33 4.3.6.52 4.3.6.19 4.3.6.58 4.3.6.42 (5 Replies)
Discussion started by: dnam9917
5 Replies

6. Shell Programming and Scripting

Alternate to sort --random-sort

sort --random-sort The full command is path=`find /testdir -maxdepth 1 -mindepth 1 -type d | ***Some sort of sort function*** | head -1` I have a list I want to randomly sort. It works fine in ubuntu but on a 'osx lion' sort dosen't have the --random-sort option. I don't want to... (5 Replies)
Discussion started by: digitalviking
5 Replies

7. Shell Programming and Scripting

Help with sort word and general numeric sort at the same time

Input file: 100%ABC2 3.44E-12 USA A2M%H02579 0E0 UK 100%ABC2 5.34E-8 UK 100%ABC2 3.25E-12 USA A2M%H02579 5E-45 UK Output file: 100%ABC2 3.44E-12 USA 100%ABC2 3.25E-12 USA 100%ABC2 5.34E-8 UK A2M%H02579 0E0 UK A2M%H02579 5E-45 UK Code try: sort -k1,1 -g -k2 -r input.txt... (2 Replies)
Discussion started by: perl_beginner
2 Replies

8. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

Hi Experts, I have a filelist collected from another server , now want to sort the output using date/time stamp filed. - Filed 6, 7,8 are showing the date/time/stamp. Here is the input: #---------------------------------------------------------------------- -rw------- 1 root ... (3 Replies)
Discussion started by: rveri
3 Replies

9. UNIX for Beginners Questions & Answers

Difference of Sort -n -k2 -k3 & Sort -n -k2,3

Hi, Could anyone kindly show me a link or explain the difference between sort -n -k2 -k3 & sort -n -k2,3 Also, if I like to remove the row with repetition at both $2 and $3, Can I safely use sort -u -k2 -k3 Example; 100 20 30 100 20 30 So, both $2 and $3 are same and I... (2 Replies)
Discussion started by: Indra2011
2 Replies

10. Shell Programming and Scripting

Use sort to sort numerical column

How to sort the following output based on lowest to highest BE? The following sort does not work. $ sort -t. -k1,1n -k2,2n bfd.txt BE31.116 0s 0s DOWN DAMP BE31.116 0s 0s DOWN DAMP BE31.117 0s 0s ... (7 Replies)
Discussion started by: sand1234
7 Replies
NTFS-3G.USERMAP(8)					      System Manager's Manual						NTFS-3G.USERMAP(8)

NAME
ntfs-3g.usermap - NTFS Building a User Mapping File SYNOPSIS
ntfs-3g.usermap windows-system-device [other-ntfs-device...] Where windows-system-device is the device containing the Windows system whose users are to be mapped to current Linux system. And other-ntfs-device is another device containing files which are to be accessed both by the Windows mentioned above and current Linux system. the ntfs-3g.usermap command must be started as root, and the designated devices must not be mounted. Typing ntfs-3g.usermap with no args will display a summary of command arguments. DESCRIPTION
ntfs-3g.usermap creates the file defining the mapping of Windows accounts to Linux logins for users who owns files which should be visible from both Windows and Linux. It relies on existing files which were created on Windows, trying to locate significant files and asking which Linux user or group should own them. When a Linux owner or group is requested, the reply may be : - the uid or gid (numeric or symbolic) of Linux owner or group of the file. In that situation, no more file with the same Windows owner will be selected. - or no answer, when not able to define the owner or group. In that situation another file owned by the same Windows user or group may be selected later so that a mapping can be defined. The mappings for standard Windows users, such as "Administrator" or "All Users" are defined implicitly. As a consequence a user mapping should never be defined as Linux root. When there are no more significant files, ntfs-3g.usermap create the mapping file into the file UserMapping in the current directory. This file has to be moved to the hidden directory .NTFS-3G in the root of all the NTFS file systems to be shared between Windows and Linux. This requires the file system to be mounted, but the created file will not be taken into account if not present at mount time, which means the file system has to be unmounted and mounted again for the new mapping file to be taken into account. OPTIONS
No option is defined for ntfs-3g.usermap. EXAMPLES
Map the users defined on the Windows system present on /dev/sda1 : ntfs-3g.usermap /dev/sda1 A detailed example, with screen displays is available on http://pagesperso-orange.fr/b.andre/usermap.html EXIT CODES
ntfs-3g.usermap exits with a value of 0 when no error was detected, and with a value of 1 when an error was detected. KNOWN ISSUES
Please see http://www.tuxera.com/community/ntfs-3g-faq/ for common questions and known issues. If you would find a new one in the latest release of the software then please send an email describing it in detail. You can contact the development team on the ntfs-3g-devel@lists.sf.net address. AUTHORS
ntfs-3g.secaudit has been developed by Jean-Pierre Andre. THANKS
Several people made heroic efforts, often over five or more years which resulted the ntfs-3g driver. Most importantly they are Anton Alta- parmakov, Richard Russon, Szabolcs Szakacsits, Yura Pakhuchiy, Yuval Fledel, and the author of the groundbreaking FUSE filesystem develop- ment framework, Miklos Szeredi. SEE ALSO
ntfsprogs(8), attr(5), getfattr(1) ntfs-3g.usermap 1.1.2 February 2010 NTFS-3G.USERMAP(8)
All times are GMT -4. The time now is 02:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy