Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How can I better group my output? Post 302165364 by vgersh99 on Thursday 7th of February 2008 03:59:42 PM
Old 02-07-2008
Quote:
Originally Posted by llsmr777
Well in my real list the list with bb1 - could be 20 lines and bb2 - 10 and sl1 30 - instead of just what's listed below. And the numbers can change.

thanks for your reply!!!

bb1 newyork
bb1 pittsburg

bb2 seattle
bb2 spokane

sl1 sacramento
assuming your file is sorted on the FIRST column:
Code:
nawk 'f != $1 {
     if (FNR!=1) print ""
     f=$1
}
1' myFile

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk help required to group output and print a part of group line and original line

Hi, Need awk help to group and print lines to format the output as shown below INPUT FORMAT set echo on set heading on set spool on /* SCHEMA1 */ CREATE TABLE T1; /* SCHEMA1 */ CREATE TABLE T2; /* SCHEMA1 */ CREATE TABLE T3; /* SCHEMA1 */ CREATE TABLE T4; /* SCHEMA1 */ CREATE TABLE T5;... (5 Replies)
Discussion started by: rajan_san
5 Replies

2. UNIX for Dummies Questions & Answers

output of file from several machines written to network share, then emailed to group.

I have a script on all the machines on my network that lists how many updates are available for each machine, and then outputs the answer to a file called updates.txt the output shows the hostname and the number of updates, like: computer_A 7 I want all these machines to output the data to... (1 Reply)
Discussion started by: glev2005
1 Replies

3. Shell Programming and Scripting

Group the output of the variable

Hi Guys, First time in scripting & first time here...:D I need help in this situation - My requirements is: I have a list e.g. list=`echo ls -l *` OR list=`sql.... select emp_id from employee ...` The Input is: ls -l OR emp_id A 4567 B 2231 C ... (2 Replies)
Discussion started by: alvingo
2 Replies

4. Shell Programming and Scripting

How to group the output of a loop

Hi Guys, This is based on my question previously posted. :) I have my shell script like this: #!/usr/bin/sh e_id=`sqlplus -s scott/tiger@DB<<eof SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF; select emp_id from employee; quit ... (1 Reply)
Discussion started by: alvingo
1 Replies

5. Shell Programming and Scripting

How to group the output w/ limit

Hi All, Second time to post on this group :) I'm pulling my hair now 'coz I'm so dumb to produce this requirement. Requirement: I want to run a utility by limiting the no. inside my process (mov##) to be able to use in multi streaming. Here is my script: --Input: "user_list.txt"... (0 Replies)
Discussion started by: alvingo
0 Replies

6. Shell Programming and Scripting

ID - output group-memberships one per line

Hello, I am currently a little bit lost with my new shell-script. I am trying to output the results of the "id"-command as a "one per line" statement. For example: I have the user "test" with the group-memberships "group1, group2, group3". When I enter "id test" it will show me the output... (2 Replies)
Discussion started by: henryford
2 Replies

7. Shell Programming and Scripting

need a one liner to grep a group info from /etc/group and use that result to search passwd file

/etc/group tiadm::345:mk789,po312,jo343,ju454,ko453,yx879,iy345,hn453 bin::2:root,daemon sys::3:root,bin,adm adm::4:root,daemon uucp::5:root /etc/passwd mk789:x:234:1::/export/home/dummy:/bin/sh po312:x:234:1::/export/home/dummy:/bin/sh ju454:x:234:1::/export/home/dummy:/bin/sh... (6 Replies)
Discussion started by: chidori
6 Replies

8. Shell Programming and Scripting

Joining multi-line output to a single line in a group

Hi, My Oracle query is returing below o/p ---------------------------------------------------------- Ins trnas value a lkp1 x a lkp1 y b lkp1 a b lkp2 x b lkp2 y ... (7 Replies)
Discussion started by: gvk25
7 Replies

9. Programming

Sql ORA-00937: not a single-group group function

I'm trying to return only one row with the highest value for PCT_MAX_USED. Any suggestions? When I add this code, I get the ORA-00937 error. trunc(max(decode( kbytes_max, 0, 0, (kbytes_alloc/kbytes_max)*100))) pct_max_used This is the original and returns all rows. select (select... (3 Replies)
Discussion started by: progkcp
3 Replies
XMLSORT(1p)						User Contributed Perl Documentation					       XMLSORT(1p)

NAME
xmlsort - sorts 'records' in XML files SYNOPSIS
xmlsort -r=<recordname> [ <other options> ] [ <filename> ] Options: -r <name> name of the elements to be sorted -k <keys> child nodes to be used as sort keys -i ignore case when sorting -s normalise whitespace when comparing sort keys -t <dir> buffer records to named directory rather than in memory -m <bytes> set memory chunk size for disk buffering -h help - display the full documentation Example: xmlsort -r 'person' -k 'lastname;firstname' -i -s in.xml >out.xml DESCRIPTION
This script takes an XML document either on STDIN or from a named file and writes a sorted version of the file to STDOUT. The "-r" option should be used to identify 'records' in the document - the bits you want sorted. Elements before and after the records will be unaffected by the sort. OPTIONS
Here is a brief summary of the command line options (and the XML::Filter::Sort options which they correspond to). For more details see XML::Filter::Sort. -r <recordname> (Record) The name of the elements to be sorted. This can be a simple element name like 'person' or a pathname like 'employees/person' (only person elements contained directly within an employees element). -k <keys> (Keys) Semicolon separated list of elements (or attributes) within a record which should be used as sort keys. Each key can optionally be followed by 'alpha' or 'num' to indicate alphanumeric of numeric sorting and 'asc' or 'desc' for ascending or descending order (eg: -k 'lastname;firstname;age,n,d'). -i (IgnoreCase) This option makes sort comparisons case insensitive. -s (NormaliseKeySpace) By default all whitespace in the sort key elements is considered significant. Specifying -s will case leading and trailing whitespace to be stripped and internal whitespace runs to be collapsed to a single space. -t <directory> (TempDir) When sorting large documents, it may be prudent to use disk buffering rather than memory buffering. This option allows you to specify where temporary files should be written. -m <bytes> (MaxMem) If you use the -t option to enable disk buffering, records will be collected in memory in 'chunks' of up to about 10 megabytes before being sorted and spooled to temporary files. This option allows you to specify a larger chunk size. A suffix of K or M indicates kilobytes or megabytes respectively. SEE ALSO
This script uses the following modules: XML::SAX::ParserFactory XML::Filter::Sort XML::SAX::Writer AUTHOR
Grant McLean <grantm@cpan.org> COPYRIGHT
Copyright (c) 2002 Grant McLean. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.4 2002-06-14 XMLSORT(1p)
All times are GMT -4. The time now is 01:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy