The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sorting a file mtechnocrat UNIX for Dummies Questions & Answers 11 06-28-2007 04:28 AM
file sorting phani_sree Shell Programming and Scripting 5 02-04-2007 11:39 PM
need help with sorting a file pieman8080 Shell Programming and Scripting 5 11-21-2006 10:50 AM
Sorting a file Khoomfire Shell Programming and Scripting 2 12-13-2005 04:48 AM
Help sorting file. gio123bg Shell Programming and Scripting 3 12-10-2003 07:15 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 02-02-2007
Registered User
 

Join Date: Nov 2006
Posts: 52
regarding file sorting

i ahve a file like:
*************************************
sree
122132
12321
***********************************
phani
21321
3213214
******************************
dddsds
213213123
23213213
*******************************
i want to sort the file with respect to name how we can do this
thank u
sree
Reply With Quote
Forum Sponsor
  #2  
Old 02-02-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,274
Code:
awk '{
     if(index($0,"*")==1 && NR > 1) { printf("\n") }
     printf("%s|", $0)  
    }
    END { printf("\n") }
    '  filename | sort | tr -s '|' '\n' > sortedfile
filename:
Code:
    
*************************************
sree
122132
12321
*************************************
phani
21321
3213214
*************************************
dddsds
213213123
23213213
*************************************
zzzzzzz
9999999
8888888
output in sortedfile:
Code:
*************************************
dddsds
213213123
23213213
*************************************
phani
21321
3213214
*************************************
sree
122132
12321
*************************************
zzzzzzz
9999999
8888888
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0