Sponsored Content
Full Discussion: Sort, group rows
Top Forums Shell Programming and Scripting Sort, group rows Post 302273924 by patrykxes on Tuesday 6th of January 2009 08:04:59 AM
Old 01-06-2009
Hi

Source report:

User1,admin,rep,User2,shell,path1,x1,r1
User2,admin,rep,User7,shell,path1,x1,r1
User3,admin,rep,User4,shell,path1,x1,r1
User4,admin,rep,User3,shell,path1,x1,r1
User5,admin,rep,User1,shell,path1,x1,r1
User6,admin,rep,User5,shell,path1,x1,r1
User7,admin,rep,User6,shell,path1,x1,r1
User8,admin,rep,,,path1,x1,r1
User9,admin,rep,,,path1,x1,r1
User10,admin,rep,,,path1,x1,r1
User11,admin,rep,,,path1,x1,r1
...

I'd like to assign user names with numbers User2,User7,User4,User3,User1... from the fourth column to the same users from the first column, so as to obtain the following report:

User1,admin,rep,User1,shell,path1,x1,r1
User2,admin,rep,User2,shell,path1,x1,r1
User3,admin,rep,User3,shell,path1,x1,r1
User4,admin,rep,User4,shell,path1,x1,r1
User5,admin,rep,User5,shell,path1,x1,r1
User6,admin,rep,User6,shell,path1,x1,r1
User7,admin,rep,User7,shell,path1,x1,r1
User8,admin,rep,,,path1,x1,r1
User9,admin,rep,,,path1,x1,r1
User10,admin,rep,,,path1,x1,r1
User11,admin,rep,,,path1,x1,r1
...

ps.
only users User2,User7,User4,User3,User1... from the fourth column have shell
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sort cmd to get GROUP BY?

Is there any way using the sort command to get something like a GROUP BY clause? I'm trying to sort through race_event records and group them by those individuals that raced together in the same race on the same date at the same track, but i run into a problem when there were days when the track... (6 Replies)
Discussion started by: RacerX
6 Replies

2. Shell Programming and Scripting

Sort the multi column rows

abc xyz - - - - - - - - - - - How to sort the second column in ascending order. (2 Replies)
Discussion started by: sandy1028
2 Replies

3. Shell Programming and Scripting

Convert rows to columns group

Hi I have the input file following like this "AIX" "AIX 6.0" "AIX 7.0" "Redhat 8" "Redhat 9" "Redhat 5.0 Enterprise Linux" "Sun Solaris 9" "Sun Solaris 10", "Sun Microsystems" "Oracle" .................................Like this 2000 lines I need to convert this input into... (5 Replies)
Discussion started by: selvanraj
5 Replies

4. Shell Programming and Scripting

Sort the file contents in each group....print the group title as well

I've this file and need to sort the data in each group File would look like this ... cat file1.txt Reason : ABC 12345-0023 32123-5400 32442-5333 Reason : DEF 42523-3453 23345-3311 Reason : HIJ 454553-0001 I would like to sort each group on the last 4 fileds and print them... (11 Replies)
Discussion started by: prash184u
11 Replies

5. Shell Programming and Scripting

Sort Data by Group !

Hello, I have a file and i want to sort by third column and extract the three top lines of each group, it is determined by the second column (144, 89, 55, etc). Could you please help me with the appropiate awk shell script XLY-XLP 144 0.592772 XLY-XLE 144 0.798121 ... (3 Replies)
Discussion started by: csierra
3 Replies

6. Shell Programming and Scripting

Awk: group rows by id and simple conversion

Hi all, I am a newbie to awk and trying to learn by doing examples. I got stuck at this relatively simple conversion. The start file looks like: 1 2 "t1" 1 3 "h1" 2 1 "h1" 2 2 "h2" and I want to convert it into 1 t1:2, h1:3; 2 h1:1, h2:2; Thanks. (9 Replies)
Discussion started by: eagle_fly
9 Replies

7. UNIX for Dummies Questions & Answers

Converting Columns To Rows Sort Of

Hi I'm a UNIX awk and sed novice at best. I'm trying to creat a .csv file so it can be graphed in Excel. Tried various xargs, awk, sed and paste but just can't seem to get the data to line up. Not sure if this is beyond for a question in these forums. Any help would greatly be appreciated. Have... (4 Replies)
Discussion started by: jimmyf
4 Replies

8. Shell Programming and Scripting

Group by and translate rows to column

I've a comma separated file with data below: 61401370587,505,1;0402686146,123;2387936.0;20170812 61401370587,505,2;0401296221,34;3.0;20170811 61401370587,505,5;0431169322,123;2387936.0;20170812 My requirement is to group by using 1st,2nd column . And translate the 3rd column's row data... (1 Reply)
Discussion started by: bhagat-reena
1 Replies

9. Shell Programming and Scripting

Rearrange rows by group pairs

Hello gurus, I have two variable columns 1 and 2 , and their respective groups in 3 and 4 var1 var2 gr1 gr2 a b g h c d h g d f d h f g h g d r h d p q a b h y h g r t g h I want to rearrange the rows in such a way that all similarly grouped (var1 var2) pairs are together . The... (4 Replies)
Discussion started by: senhia83
4 Replies

10. Shell Programming and Scripting

Sort by id value in every two rows

Hello, I am running ubuntu 14.04. My purpose is to sort below file according to value of id even though it contains alphanumeric strings inside double quote. File is not tab separated. I am not sure that can be done... mydata #INFO id="133 texas" logo="http://tx.yy.zz http://11.22.48 #INFO... (3 Replies)
Discussion started by: baris35
3 Replies
rt-email-group-admin(8) 				     Request Tracker Reference					   rt-email-group-admin(8)

NAME
rt-email-group-admin - Command line tool for administrating NotifyGroup actions SYNOPSIS
rt-email-group-admin --list rt-email-group-admin --create 'Notify foo team' --group Foo rt-email-group-admin --create 'Notify foo team as comment' --comment --group Foo rt-email-group-admin --create 'Notify group Foo and Bar' --group Foo --group Bar rt-email-group-admin --create 'Notify user foo@bar.com' --user foo@bar.com rt-email-group-admin --create 'Notify VIPs' --user vip1@bar.com rt-email-group-admin --add 'Notify VIPs' --user vip2@bar.com --group vip1 --user vip3@foo.com rt-email-group-admin --rename 'Notify VIPs' --newname 'Inform VIPs' rt-email-group-admin --switch 'Notify VIPs' rt-email-group-admin --delete 'Notify user foo@bar.com' DESCRIPTION
This script list, create, modify or delete scrip actions in the RT DB. Once you've created an action you can use it in a scrip. For example you can create the following action using this script: rt-email-group-admin --create 'Notify developers' --group 'Development Team' Then you can add the followoing scrip to your Bugs queue: Condition: On Create Action: Notify developers Template: Transaction Stage: TransactionCreate Your development team will be notified on every new ticket in the queue. USAGE
rt-email-group-admin --COMMAND ARGS COMMANDS
list Lists actions and its descriptions. create NAME [--comment] [--group GNAME] [--user UNAME] Creates new action with NAME and adds users and/or groups to its recipient list. Would be notify as comment if --comment specified. add NAME [--group GNAME] [--user UNAME] Adds groups and/or users to recipients of the action NAME. delete NAME Deletes action NAME if scrips doesn't use it. switch NAME Switch action NAME from notify as correspondence to comment and back. rename NAME --newname NEWNAME Renames action NAME to NEWNAME. NOTES If command has option --group or --user then you can use it more then once, if other is not specified. AUTHOR
Ruslan U. Zakirov <ruz@bestpractical.com> SEE ALSO
RT::Action::NotifyGroup, RT::Action::NotifyGroupAsComment perl v5.14.2 2013-05-22 rt-email-group-admin(8)
All times are GMT -4. The time now is 05:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy