sort text having delimiter with "|" (pipe)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sort text having delimiter with "|" (pipe)
# 1  
Old 11-03-2011
sort text having delimiter with "|" (pipe)

i am having text file below
Code:
NARGU S S             12358      SALES REP                     |22|  Acccount/s
RAJU R B              64253     SALES REP                      |12|  Acccount/s
RUKMAN S              32588     SALES REP                      |10|  Acccount/s
NARGUND S S           12356     SALES REP                      |2|  Acccount/s

i want to sort it having delimiter "|"

i.e
Code:
NARGUND S S           12356     SALES REP                      |2|  Acccount/s
RUKMAN S              32588     SALES REP                      |10|  Acccount/s
RAJU R B              64253     SALES REP                      |12|  Acccount/s
NARGU S S             12358      SALES REP                     |22|  Acccount/s


pls help

Last edited by Franklin52; 11-03-2011 at 06:39 AM.. Reason: Please use code tags for data and code samples, thank you
# 2  
Old 11-03-2011
Code:
sort -t\| +1n infile

This User Gave Thanks to jayan_jay For This Post:
# 3  
Old 11-03-2011
can i get it in reverse order
# 4  
Old 11-03-2011
The same, but add an "r" as argument:
Code:
sort -t\| +1nr infile

This User Gave Thanks to felipe.vinturin For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Beginners Questions & Answers

Extract delta records using with "comm" and "sort" commands combination

Hi All, I have 2 pipe delimited files viz., file_old and file_new. I'm trying to compare these 2 files, and extract all the different rows between them into a new_file. comm -3 < sort file_old < sort file_new > new_file I am getting the below error: -ksh: sort: cannot open But if I do... (7 Replies)
Discussion started by: njny
7 Replies

3. Shell Programming and Scripting

Substituting comma "," for dot "." in a specific column when comma"," is a delimiter

Hi, I'm dealing with an issue and losing a lot of hours figuring out how i would solve this. I have an input file which looks like this: ('BLABLA +200-GRS','Serviço ','TarifaçãoServiço','wap.bla.us.0000000121',2985,0,55,' de conversão em escada','Dia','Domingos') ('BLABLA +200-GRR','Serviço... (6 Replies)
Discussion started by: poliver
6 Replies

4. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Meaning of "b" modifier in "sort" command

I need to sort the following file by the rhdiskpower devices in the last column: Total_MB Free_MB OS_MB Name Failgroup Library Label UDID Product Redund Path 1024 851 1024 OCRVOT1_0000 OCRVOT1_0000 System UNKNOWN ... (3 Replies)
Discussion started by: wjssj
3 Replies

7. Shell Programming and Scripting

Splitting text string with "|" pipe delimiters

Hi, I need to split the fields in some text strings into separate variables. The fields are separated by pipes. The strings look roughly like this: CUSTNAME|hostname|userid|gecos field|staff|disabled||SUDO Currently I can do it using something like cut -d"|" -f1, but when I put that into... (4 Replies)
Discussion started by: alanp36
4 Replies

8. Shell Programming and Scripting

sort file text by date as a "ls -t"

I have, a file wich list file on server ftp and i want to sort the file text as the command "ls -t" i.e drwxr-x--- 2 ftp_mont System 0 Sep 30 09:16 . drwxr-x--- 2 ftp_mont System 0 Jul 15 2009 .. -rwxr-x--- 1 ftp_mont System 343998791 Sep 01 09:20 manif... (14 Replies)
Discussion started by: protocomm
14 Replies

9. UNIX for Dummies Questions & Answers

Encoding Problem while using "|" (PIPE) as delimiter from Mainframe to Unix

We are facing a problem with PIPE (|) as a delimiter in one of our FTP flat files. We are constructing a Flat file in IBM-AIX and this contains various strings delimted by PIPE Symbol and then FTPing this to a Mainframe System The Mainframe program simply recieves this and FTPs the same... (1 Reply)
Discussion started by: seshendra
1 Replies

10. UNIX for Dummies Questions & Answers

Convert "text" to "packed-decimal"?

Is there a way with HP-UX Release 10.20 (but going to HP-UX 11) to convert a regular "text" file to a packed data format (such as is created by a Cobol program)? (2 Replies)
Discussion started by: HuskyJim
2 Replies
Login or Register to Ask a Question