12-02-2010
sort the file lines according to second column .. /bin/sh
the rows have to be sorted according to the second column (family name). In addition, the number of family names that start with a particular alphabet
character is put before the beginning of the series. Assume that the file have
4 columns with the following column formatting:
first name (string), family name (string), address (string), telephone number (string).
As an example, the file will have the following format after being processed by
the shell script:
before:
George, Bassam, Haifi - Carmel mount, 04-222 340
Max, Amir, Tokyo - Garden area, 295 1090
Jone, Adam, Jerusalem - Salah Eddine Street, 585 6230
after:
2
Jone, Adam, Jerusalem - Salah Eddine Street, 585 6230
Max, Amir, Tokyo - Garden area, 295 1090
1
George, Bassam, Haifi - Carmel mount, 04-222 340
i thought about this long time...please help
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Dear All,
Good day. Here i am facing some problem like below.
file contains
12345 0001 090112
14385 0001 090112
13255 0001 090112
11345 0001 090112
....
I want to sort ascending according to the first column. What will be the shell script. (4 Replies)
Discussion started by: saifurshaon
4 Replies
2. Shell Programming and Scripting
Hi,
My input file is
$cat samp
1 siva
1 raja
2 siva
1 siva
2 raja
4 venkat
i want sort this name wise...alos need to remove duplicate lines.
i am using
cat samp|awk '{print $2,$1}'|sort -u
it showing
raja 1 (3 Replies)
Discussion started by: rsivasan
3 Replies
3. Shell Programming and Scripting
Hello,
I've done
ls -ls >fileout1
When I do the sort command for +4 it sorts it bu group. When I do +5 it sorts it by date. But it's skipping the file size column. Example:
rwxr-xr-x 1 Grueben sup 65 16 Sep 13:58 cdee
How can I sort it by file size? It doesn't... (2 Replies)
Discussion started by: Grueben
2 Replies
4. Shell Programming and Scripting
i have a file in following format
1 32 3
4 6 4
4 45 1
45 4 61
54 66 4
5 65 51
56 65 1
12 32 85
now here the total number of lines are 8(they vary each time)
Now i want to select only those lines in which the values... (6 Replies)
Discussion started by: vaibhavkorde
6 Replies
5. Shell Programming and Scripting
Hello ,
i have a text file like this
1 a1 ,AB ,AC ;AD ,EE
2 a2 ,WE ;TR ,YT ,WW
3 a3 ;AS ,UY ;RF ,YT
i want to sort this text file based on each row , and excluding 2nd column from the sorting and not taking the comma or ; into consideration in the sorting, so it will become like this... (12 Replies)
Discussion started by: shelladdict
12 Replies
6. UNIX for Dummies Questions & Answers
Hello everyone!
As the heading reads, I would like to sort the lines of a text file, starting at a specific column (i.e. skip the first X characters of each line).
What I’m actually trying to sort is the md5 sums file of a directory. Every time I copy a new file to that directory, I perform... (3 Replies)
Discussion started by: iznogoud
3 Replies
7. UNIX for Dummies Questions & Answers
Hi,
Can anybody tell me how to sort a unix file by 3rd column and not by ltr? Please help
Thanks in advance (2 Replies)
Discussion started by: vinnyvirk
2 Replies
8. Shell Programming and Scripting
Hello All,
I have a file which have content as below.
03/09/2014 10:35 AM 618 Admin\rick pqr_ klm2_pog12_20140309_c.xlsx
03/10/2014 10:35 AM 618 user\test01 mplz_ fgh2_lal12_20140310_c.xlsx
03/17/2014 10:35 AM 618 Admin\vick abc_ xyz2_bc12_20140317_c.xlsx
03/18/2014 ... (2 Replies)
Discussion started by: kumar30213
2 Replies
9. UNIX for Beginners Questions & Answers
I have to sort the 4th column of an excel/csv file. I tried the following command
sort -u --field-separator=, --numeric-sort -k 2 -n dinesh.csv > test.csv
But, it's not working. Moreover, I have to do the same for more than 30 excel/csv file. So please help me to do the same. (6 Replies)
Discussion started by: dineshkumarsrk
6 Replies
10. UNIX for Beginners Questions & Answers
I have a csv file as shown below,
xop_thy 80 avr_njk 50 str_nyu 60
avr_irt 70 str_nhj 60 avr_ngt 50
str_tgt 80 xop_nmg 50 xop_nth 40
cyv_gty 40 cop_thl 40 vir_tyk 80
vir_plo 20 vir_thk 40 ijk_yuc 70
cop_thy 70 ijk_yuc 80 irt_hgt 80
I need to align/sort the csv file based... (7 Replies)
Discussion started by: dineshkumarsrk
7 Replies
LEARN ABOUT HPUX
cmpt_get_addrcid
cmpt_get_ifcid(3) Library Functions Manual cmpt_get_ifcid(3)
NAME
cmpt_get_ifcid(), cmpt_get_addrcid() - get the compartment IDs associated with a network interfaces
SYNOPSIS
Parameters
ifname Pointer to network interface name string.
family Address family of the ipaddress specified. Currently, the AF_INET and AF_INET6 address families are supported.
addr Points to a buffer holding an IPv4 address if the family argument is AF_INET or an IPv6 address if the family is AF_INET6.
The address should be in numeric format in the network byte order. Numeric format is the binary value that goes into a
socket address structure.
The binary value is the hex representation of the IPv4/IPv6 address. This binary value resides in the structure for IPv4
address and in the structure for IPv6 address. (See inet(3N) for more details.)
mask Network mask in the CIDR representation.
DESCRIPTION
The function returns the compartment ID associated with a network interface.
The function returns the compartment ID of the tuple as set by a previous invocation of the command.
RETURN VALUE
The functions and return the following values:
Successful completion.
n is the compartment of the interface or the tuple.
Function failed.
may be set to indicate the error.
ERRORS
If any of the following conditions occur, and fails and sets
Compartmentalization feature is not supported.
The process does not have the appropriate privilege.
See privileges(5).
Specified interface or the address tuple has no compartment mapping.
Specified mask or family is invalid.
DEPENDENCIES
These functions are a part of the library.
SEE ALSO
compartments(4), compartments(5), privileges(5).
cmpt_get_ifcid(3)