Sponsored Content
Full Discussion: Shell script - group by
Top Forums Shell Programming and Scripting Shell script - group by Post 302899956 by baladelaware73 on Friday 2nd of May 2014 03:54:17 PM
Old 05-02-2014
Lightbulb Shell script - group by

Hi,
I have text file as shown below.

Code:
root 25 oracle 25  batch 30  griduser 32 admin 35
root 25 oracle 25  batch 30  griduser 32
oracle 25  batch 30  griduser 32 xuser 45 admin 35

I want to group by based on user name, and the output need to be as below. Not necessary the username to be in order, but group by has to be done based on the username value.

Code:
root 50 oracle 75  batch 90  griduser 64 user 45 admin 70

Please help.
Thanks

---------- Post updated at 03:54 PM ---------- Previous update was at 03:52 PM ----------

typo error, pasting the correct output

Code:
root 50 oracle 75 batch 90 griduser 96 user 45 admin 70


Last edited by Scrutinizer; 05-03-2014 at 03:24 AM.. Reason: CODE tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

HELP! Group by in shell script (awk/sed?)

Hello, Could some expert soul please help me with this? I have following file format - task time abc 5 xyz 4 abc 5 xyz 3 ddd 10 ddd 2 I need to generate output as - task ... (5 Replies)
Discussion started by: sncoupons
5 Replies

2. Shell Programming and Scripting

Shell script to rename a group of files

Hello, I am having 1800 files in a directory with a specified format, like amms_850o_prod.000003uNy amms_850o_prod.000003u8x amms_850o_prod.000003taP amms_850o_prod.000003tKy amms_850o_prod.000003si4 amms_850o_prod.000003sTP amms_850o_prod.000003sBg amms_850o_prod.000003rvx... (12 Replies)
Discussion started by: atlantis
12 Replies

3. Shell Programming and Scripting

"group by" using shell script?

not sure if it's called "group by" , but what i'm going to do is like this: i have a file below: 192.168.1.10 192.168.1.10 192.168.1.10 192.168.1.11 192.168.1.15 192.168.1.15 192.168.1.20 192.168.1.22 then i hope to get the result like this: 192.168.1.10 : 3 192.168.1.11 : 1... (6 Replies)
Discussion started by: tiger2000
6 Replies

4. Solaris

su: No shell/No directory! if sys is added to a users secondary group

Hi, When I include a user to the secondary group "sys" GID=3 in Solaris 9 OS I'm not able to login. I get these error. The user home directory and the shell exists. Is this because of any security hardening. # su - agent No directory! # su agent su: No shell # grep taddm /etc/passwd... (14 Replies)
Discussion started by: agent001
14 Replies

5. Shell Programming and Scripting

Shell Script to ignore # and take corresponding user and group

Hi, I have a following file: role.IMPACT_USER.user=admin role.IMPACT_USER.user=dd12345 role.IMPACT_USER.user=ss76767 #role.IMPACT_USER.user=root #role.IMPACT_USER.group=System role.IMPACT_USER.group=ImpactUser #Description: Allow users to login in to Impact, start and stop service... (5 Replies)
Discussion started by: dbashyam
5 Replies

6. Shell Programming and Scripting

Help Linux Shell Group exists

I am having some problems when writing shell as follows: shell runs but returns no results echo "enter group name: " dir="/home" read group if id -g $group > /dev/null 2>&1 then echo "group exits" else echo... (6 Replies)
Discussion started by: kingkner
6 Replies

7. Shell Programming and Scripting

Help me to perform count & group by operation in shell scripting?

Hi All, I want to display the distinct values in the file and for each distinct value how may occurance or there. Test data: test1.dat 20121105 20121105 20121105 20121105 20121106 20121106 20121106 20121105 I need to display the output like Output (2 Replies)
Discussion started by: bbc17484
2 Replies

8. Shell Programming and Scripting

Shell Script to Group by Based on Multiple Fields in a file

Hi, I want to know if there is any simple approach to SUM a field based on group by of different fields for e.g. file1.txt contains below data 20160622|XXX1||50.00||50.00|MONEY|Plan1| 20160622|XXX1||100.00||100.00|MONEY|Plan1| 20160623|XXX1||25.00||25.00|MONEY|Plan1|... (3 Replies)
Discussion started by: cnu_theprince
3 Replies

9. Shell Programming and Scripting

Emulate group-by in shell script

Hello All, I saw this problem on one of the forum and solved it using group-by in oracle sql, though I am a bit curious to implement it using shell script : There is a file having number of operations : Opeation,Time-Taken operation1,83621 operation2,72321 operation3,13288... (11 Replies)
Discussion started by: mukulverma2408
11 Replies
ipsec_config_batch(1M)													    ipsec_config_batch(1M)

NAME
ipsec_config_batch - allow for processing of IPsec config operations in a single batch file SYNOPSIS
batch_file_name profile_file] DESCRIPTION
The command allows you to specify multiple and operations in a single batch file for processing. HP-UX IPSec processes the operations in a batch file as a group. This mode is useful if you are adding or deleting configuration records that may affect other records. If one operation is invalid, all operations in the batch file fail. The utility first verifies each operation in the batch file for syntax errors and collisions (object names and priority values) with existing entries in the configuration database. If all operations in the batch file are valid, the HP-UX IPSec infrastructure updates the configuration database with all operations at the same time. If HP-UX IPSec is active and running, the HP-UX IPSec infrastructure also updates the runtime policy database. Options and Operands The batch operation recognizes the following options and operands: batch_file_name The name of the batch file containing and operations. A batch file cannot contain operations that operate on the following objects: For example, the operation is illegal in a batch file. In addition, a batch file cannot contain the following commands: o does not allow recursive batch files) or commands. o o Lines starting with a pound sign are interpreted as comments. Comment lines within an operation are not allowed. Maximum length: 1023 characters. Default: None. The utility verifies the and operations, but does not add or delete entries in the configuration database. This option applies to all operations in the batch file. Individual operations in the batch file cannot specify the option. Specifies the name of the profile file containing default argument values for this policy. The argument values are evaluated once, when the policy is added to the configuration database. Val- ues used from the profile file become part of the configuration record for the policy. This argument applies to all operations in the batch file. Individual operations in the batch file cannot specify the profile argument. Maximum length: 1023 characters. Default: EXAMPLES
The file contains the following entries: AUTHOR
was developed by HP. FILES
configuration database. default profile file. SEE ALSO
ipsec_admin(1M), ipsec_config(1M), ipsec_config_add(1M), ipsec_config_delete(1M), ipsec_config_export(1M), ipsec_config_show(1M), ipsec_migrate(1M), ipsec_policy(1M), ipsec_report(1M). HP-UX IPSec Software Required ipsec_config_batch(1M)
All times are GMT -4. The time now is 09:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy