![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
awk '{
if(index($0,"*")==1 && NR > 1) { printf("\n") }
printf("%s|", $0)
}
END { printf("\n") }
' filename | sort | tr -s '|' '\n' > sortedfile
Code:
************************************* sree 122132 12321 ************************************* phani 21321 3213214 ************************************* dddsds 213213123 23213213 ************************************* zzzzzzz 9999999 8888888 Code:
************************************* dddsds 213213123 23213213 ************************************* phani 21321 3213214 ************************************* sree 122132 12321 ************************************* zzzzzzz 9999999 8888888 |
|||
| Google The UNIX and Linux Forums |