Sponsored Content
Top Forums Shell Programming and Scripting Sort based on Multiple Columns in UNIX Post 302833431 by DevendraG on Wednesday 17th of July 2013 05:52:07 AM
Old 07-17-2013
Thanks.

Is there a way I can add a Counter Field at the end of each line. This Counter will keep a track of each occurrence of 1st Field.

For instance:
Code:
1234567890;11113333222244;11-1x;3_File.xml;Try-1
1234567890;11112222333344;11-1x;1_File.xml;Try-2
1678923450;11112222333344;11-1x;2_File.xml;Try-1

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help needed to sort multiple columns in one file

Hi, I would like to know given that I have 3 columns. Let say I have first 3 columns to do operation and these operation output is printed out each line by line using AWK and associative array.Currently in the output file, I do a sort by -r for the operation output. The problem comes to... (1 Reply)
Discussion started by: ahjiefreak
1 Replies

2. Shell Programming and Scripting

Remove lines, Sorted with Time based columns using AWK & SORT

Hi having a file as follows MediaErr.log 84 Server1 Policy1 Schedule1 master1 05/08/2008 02:12:16 84 Server1 Policy1 Schedule1 master1 05/08/2008 02:22:47 84 Server1 Policy1 Schedule1 master1 05/08/2008 03:41:26 84 Server1 Policy1 ... (1 Reply)
Discussion started by: karthikn7974
1 Replies

3. Shell Programming and Scripting

sort by multiple columns and reformat...

hello.. I have big file and so far I was able to shink it and make smaller with certains values that I need.. vendor1|2000|1 vendor2|1000|1 vendor2|5000|1 vendor2|500|2 vendor3|1000|2 vendor3|500|3 vendor4|500|3 Vendor5|500|1 vendor6|500|3 Vendor7|1000|1 Vendor8|1000|774... (3 Replies)
Discussion started by: abdulaziz
3 Replies

4. Shell Programming and Scripting

sort by based on multiple columns

Hi, Is there any way to sort a file in cshell by sort command, sorting it by multiple fields, like to sort it first by the second column and then by the first column. Thanks forhead (1 Reply)
Discussion started by: Takeeshe
1 Replies

5. Shell Programming and Scripting

sort on multiple columns

Howdy! Need to sort a large .txt file containing the following, using sort. First based on the 1st column, and then on the 2nd column: Group01.01 1000500 31 0.913 -1.522974494 Group01.01 1001500 16 0.684 -0.967496041 Group01.01 36500 19 0.476 na Group01.02 365500 15 0.400 na... (1 Reply)
Discussion started by: sramirez
1 Replies

6. Shell Programming and Scripting

sort on multiple columns

hi all, i have a file , having few columns. i wanted to sort it based on 2nd column and then based on 1st column. But i have some problem in first column. first column have characters and numbers, but problem is number of characters are not same in all rows. Few rows have 13 characters and then... (3 Replies)
Discussion started by: deepakiniimt
3 Replies

7. Shell Programming and Scripting

Sort and join multiple columns using awk

Is it possible to join all the values after sorting them based on 1st column key and replace empty rows with 0 like below ? input a1 0 a1 1 a1 1 a3 1 b2 1 a2 1 a4 1 a2 1 a4 1 c4 1 a3 1 d1 1 a3 1 b1 1 d1 1 a4 1 c4 1 b2 1 b1 1 b2 1 c4 1 d1 1 output... (8 Replies)
Discussion started by: quincyjones
8 Replies

8. UNIX for Dummies Questions & Answers

UNIX Sort on a field that spans multiple columns

New to unix. I need to sort the records of a file by a control number field. That field is in POS 16 through 28. How do I do that? There are no delimiters, or spaces to separate fields. See example below. Each line is a record. REC1CCYYMMDD0018888888888888ABCDE... (1 Reply)
Discussion started by: jclanc8
1 Replies

9. Programming

Ls -ltr Sort multiple columns

Hi All, I have one requirement, where I need to have output of ls -l command sorted on 1) first on filename 2) last modified time ( descending ) - latest change first. I am not able to figure out how to do it.. Also I dont have a way to change Date display for ls -ltr command.. I am... (1 Reply)
Discussion started by: freakabhi
1 Replies

10. UNIX for Beginners Questions & Answers

Sort and remove duplicates in directory based on first 5 columns:

I have /tmp dir with filename as: 010020001_S-FOR-Sort-SYEXC_20160229_2212101.marker 010020001_S-FOR-Sort-SYEXC_20160229_2212102.marker 010020001-S-XOR-Sort-SYEXC_20160229_2212104.marker 010020001-S-XOR-Sort-SYEXC_20160229_2212105.marker 010020001_S-ZOR-Sort-SYEXC_20160229_2212106.marker... (4 Replies)
Discussion started by: gnnsprapa
4 Replies
VGS(8)                                                        System Manager's Manual                                                       VGS(8)

NAME
vgs - report information about volume groups SYNOPSIS
vgs [-a|--all] [--aligned] [-d|--debug] [-h|-?|--help] [--ignorelockingfailure] [--nameprefixes] [--noheadings] [--nosuffix] [-o|--options [+]Field[,Field]] [-O|--sort [+|-]Key1[,[+|-]Key2[,...]]] [-P|--partial] [--rows] [--separator Separator] [--unbuffered] [--units hHbB- sSkKmMgGtTpPeE] [--unquoted] [-v|--verbose] [--version] [VolumeGroupName [VolumeGroupName...]] DESCRIPTION
vgs produces formatted output about volume groups. OPTIONS
See lvm for common options. --all List all volume groups. Equivalent to not specifying any volume groups. --aligned Use with --separator to align the output columns. --nameprefixes Add an "LVM2_" prefix plus the field name to the output. Useful with --noheadings to produce a list of field=value pairs that can be used to set environment variables (for example, in udev (7) rules). --noheadings Suppress the headings line that is normally the first line of output. Useful if grepping the output. --nosuffix Suppress the suffix on output sizes. Use with --units (except h and H) if processing the output. -o, --options Comma-separated ordered list of columns. Precede the list with '+' to append to the default selection of columns. Use -o vg_all to select all volume group columns. Use -o help to view the full list of columns available. Column names include: vg_fmt, vg_uuid, vg_name, vg_attr, vg_size, vg_free, vg_sysid, vg_extent_size, vg_extent_count, vg_free_count, max_lv, max_pv, pv_count, lv_count, snap_count, vg_seqno, vg_tags, vg_mda_count, vg_mda_free, and vg_mda_size, vg_mda_used_count. Any "vg_" prefixes are optional. Columns mentioned in either pvs (8) or lvs (8) can also be chosen, but columns cannot be taken from both at the same time. The vg_attr bits are: 1 Permissions: (w)riteable, (r)ead-only 2 Resi(z)eable 3 E(x)ported 4 (p)artial: one or more physical volumes belonging to the volume group are missing from the system 5 Allocation policy: (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited 6 (c)lustered -O, --sort Comma-separated ordered list of columns to sort by. Replaces the default selection. Precede any column with - for a reverse sort on that column. --rows Output columns as rows. --separator Separator String to use to separate each column. Useful if grepping the output. --unbuffered Produce output immediately without sorting or aligning the columns properly. --units hHbBsSkKmMgGtTpPeE All sizes are output in these units: (h)uman-readable, (b)ytes, (s)ectors, (k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes, (p)etabytes, (e)xabytes. Capitalise to use multiples of 1000 (S.I.) instead of 1024. Can also specify custom units e.g. --units 3M --unquoted When used with --nameprefixes, output values in the field=value pairs are not quoted. SEE ALSO
lvm(8), vgdisplay(8), pvs(8), lvs(8) Sistina Software UK LVM TOOLS 2.02.95(2) (2012-03-06) VGS(8)
All times are GMT -4. The time now is 08:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy