Help with Sort option


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with Sort option
# 1  
Old 10-13-2010
Help with Sort option

Hello,
I'm sure this is an easy one but I've tried loads of sort options and none of them work. I'm trying to sort a file by alpha-numerical order but it's not working. My file is:
Code:
SN023x
SN047x
SN085x
SN124x
SN178x
SN480x
SN1004x

After I sort it the highest number server (1004) is in the middle of the sort - It's sorting it between the 08 and 12. I want to sort the entire word so the highest number server is last!

As usual any help much appreciated!

Last edited by radoulov; 10-13-2010 at 12:37 PM.. Reason: Code tags, please!
# 2  
Old 10-13-2010
Code:
sort -k1.1,1.2 -k1.3n infile

# 3  
Old 10-13-2010
Cheers that worked fine
# 4  
Old 10-19-2010
hiiiiii

can u please explain the above code i google it but did not able to find sort with -k option and what is the meaning of 1.1

pls explain
# 5  
Old 10-19-2010
man sort
Code:
       -k  keydef
	      The  keydef  argument is a restricted sort key field definition.
	      The format of this definition is:

	      field_start[type][,field_end[type]]
[..]
              The  field_start  portion  of the keydef option-argument shall have the form:

              field_number[.first_character]
[..]
              The field_end portion of the  keydef  option-argument  shall  have  the form:

	      field_number[.last_character]

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Unrecognized option: sparc-sun-Solaris2.10/bin/as: unrecognized option `-m32'

Hi, I installed some packages required by an app built with python. But when I try python setup.py install, I get the following error: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32' Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies

2. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

Hi Experts, I have a filelist collected from another server , now want to sort the output using date/time stamp filed. - Filed 6, 7,8 are showing the date/time/stamp. Here is the input: #---------------------------------------------------------------------- -rw------- 1 root ... (3 Replies)
Discussion started by: rveri
3 Replies

3. Shell Programming and Scripting

Help with sort word and general numeric sort at the same time

Input file: 100%ABC2 3.44E-12 USA A2M%H02579 0E0 UK 100%ABC2 5.34E-8 UK 100%ABC2 3.25E-12 USA A2M%H02579 5E-45 UK Output file: 100%ABC2 3.44E-12 USA 100%ABC2 3.25E-12 USA 100%ABC2 5.34E-8 UK A2M%H02579 0E0 UK A2M%H02579 5E-45 UK Code try: sort -k1,1 -g -k2 -r input.txt... (2 Replies)
Discussion started by: perl_beginner
2 Replies

4. Shell Programming and Scripting

Alternate to sort --random-sort

sort --random-sort The full command is path=`find /testdir -maxdepth 1 -mindepth 1 -type d | ***Some sort of sort function*** | head -1` I have a list I want to randomly sort. It works fine in ubuntu but on a 'osx lion' sort dosen't have the --random-sort option. I don't want to... (5 Replies)
Discussion started by: digitalviking
5 Replies

5. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

6. Shell Programming and Scripting

sort -t option causing code to fail need ASCII character

Hello, When I run this UNIX code without the -t option it gives me the desired results. The code keeps the record with the greatest datetime based on the key columns. I sort it first then sort it again with the -u option, that's it. I need to have a variable to specify an ASCII character... (2 Replies)
Discussion started by: script_op2a
2 Replies

7. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

8. Shell Programming and Scripting

How to Sort Floating Numbers Using the Sort Command?

Hi to all. I'm trying to sort this with the Unix command sort. user1:12345678:3.5:2.5:8:1:2:3 user2:12345679:4.5:3.5:8:1:3:2 user3:12345687:5.5:2.5:6:1:3:2 user4:12345670:5.5:2.5:5:3:2:1 user5:12345671:2.5:5.5:7:2:3:1 I need to get this: user3:12345687:5.5:2.5:6:1:3:2... (7 Replies)
Discussion started by: daniel.gbaena
7 Replies

9. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies

10. UNIX for Dummies Questions & Answers

ps with --sort option

Good morning, Using command root@slackware:~# ps -e -O sz --sort sz part of the output is: PID SZ S TTY TIME COMMAND ... 57 358 S ? 00:00:00 /usr/sbin/syslogd 60 347 S ? 00:00:00 /usr/sbin/klogd -c 3 -x 103 347 S ? 00:00:00 udevd 119 ... (2 Replies)
Discussion started by: jonas.gabriel
2 Replies
Login or Register to Ask a Question