![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Enterprise Unix Roundup: The Ghost of Unix Future - Server Watch | iBot | UNIX and Linux RSS News | 0 | 12-19-2007 08:20 AM |
| Running UNIX commands remotely in Windows box from Unix box – avoid entering password | D.kalpana | UNIX for Dummies Questions & Answers | 1 | 04-20-2007 02:24 AM |
| FTP script for sending a file from one unix directory to another unix server director | raja_1234 | Shell Programming and Scripting | 1 | 11-30-2006 03:57 AM |
| Unix Sco Open Server, Windows Computers Problem Access Unix Shared Files Help!!!!! | haggo | Filesystems, Disks and Memory | 2 | 08-23-2006 08:39 AM |
| Unix History Question: Why are filenames/dirnames case sentsitive in Unix? | deckard | UNIX for Dummies Questions & Answers | 3 | 03-26-2005 09:59 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
I am a new to Unix..
I am trying to sort a file that contains alphanumeric .. I have tried the -n and -f and the file is not sorted in correct alphabetical and number order... Someone , please help..... much apppreciated..... thanks
__________________
Chanel Manohar |
| Forum Sponsor | ||
|
|
|
|||
|
Welcome to the world of unix!
Can you please be VERY specific when asking questions. You will find quick/better answers when you define your problem in detail. Can you tell us EXACTLY what you are trying to do and what command you typed on the command line and a few lines of your input file ? Best Wishes!!
__________________
FreeBSD: The best free Unix on this planet IMHO!! FreeBSD Forums www.freebsdforums.org |
|
|||
|
This is a sample of my input file...
99-xsdq0763 19-xsdq0533 04-xsdq0762 20-xsdq0551 05-xsdq0760 21-xsdq0550 06-xsd00z51 22-xsdq0850 07-xsuqcf02 23-xsdq0828 08-xsd00z12 24-xsdq0826 09-xsd00z43 25-xsdq0823 10-xsd00z35 26-xsdq0822 11-xsd00z50 27-xsdq0552 12-xsdqli01 28-xsdq0401 13-xsuqcf01 29-xsdq0750 14-xsdq0511 30-xsdq0728 15-xsdq0542 31-xsdq0726 16-xsd00e37 32-xsdq0723 I am told to sort this file in aphabetical/numeric order... I tried sort -nfd workfile but the output is not in the corredt alphabetical /numeric order...
__________________
Chanel Manohar |
|
|||
|
A question for you.... are there two columns of data - or is each row considered one entry. These things are very important things to know as it is handled quite differently.
If each row if one entry....(which I doubt but here goes) - the sort function is the one you need and it is simply used in this syntax: sort inputfile > outputfile Now if there are indeed 2 columns - and you want all data listed into one column sorted ..... i.e 01-xdsabcd 02-xdsabce ..... Then you need to get the data into one column to start with as the sort function will use the entire row as one entry or a number of fields within one entry - but won't separate them out. There may be a way using just the sort function to separate the two fields per row into a single list but I don't know it. To get the data from the original file into a single list use this (there are heaps of ways to do this i.e. awk.....): cut -c1-'11' inputfile > outputfile cut -c'13'-'24' inputfile >> outputfile sort outputfile > sorted_file (You may or may not need to put the 11, 13 and 24 into quotes depending on your system. This basically takes the first 11 characters on a row and puts it in a file. Then takes the next 11 (after the whitespace) and apends them to the end of this file. Then sorts the file in ascending order alphanumerically. Hope this helps.
__________________
Pete |
|||
| Google The UNIX and Linux Forums |