Sorting problem (SunOS 5.9 / KSH).


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sorting problem (SunOS 5.9 / KSH).
# 1  
Old 08-06-2008
Sorting problem (SunOS 5.9 / KSH).

Hi,

Can someone tell me why the "LargeFile" is coming first before the smaller files. Is there any way to list the files based on size column.

ls -g| sort -k 4
-rw-r--r-- 1 user 6117910528 Apr 28 15:04 LargeFile
-rw-r--r-- 1 user 6136832 May 30 07:23 my_20080530.tar
-rw-r--r-- 1 user 6245376 May 1 13:57 my_20080501.tar
-rw-r--r-- 1 user 6541824 Jul 30 12:55 my_20080730.tar
-rw-r--r-- 1 user 6796288 Mar 13 08:55 my_20080313.tar


Thank you.
KS
# 2  
Old 08-06-2008
You should force numeric comparison:

Code:
ls -g|sort -k4n

Some versions of ls (GNU coreutils) have the S switch (sort by file size).


Quote:
Can someone tell me why the "LargeFile" is coming first before the smaller file

Because 6117910528 sorts before 6136832 ASCIIbetically.
# 3  
Old 08-06-2008
Thank you radoulov it is sorting correctly now.

And unfortunately we do not have -S option.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Spacewalk. Problem with adding SunOS system

Hello i tryed add SunOS system to Spacewalk and see this error: # cat /etc/release Solaris 10 10/08 s10s_u6wos_07b SPARC Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms. ... (1 Reply)
Discussion started by: jess_t03
1 Replies

2. UNIX for Dummies Questions & Answers

SunOs problem running crontab -e

Hi, Whenever I run crontab -e from my remote terminal logged onto a SunOS 5.6 machine I get this: root@beauvert:~> crontab -e 3495 ----- I think I have to set the terminal/editor. These are my environment variables: root@beauvert:~> set EDITOR vi PATH ... (5 Replies)
Discussion started by: mojoman
5 Replies

3. UNIX for Advanced & Expert Users

Records mismatch while sorting in MPRAS and SunOS

Hi, As part of migrating a script from SunOS to MP RAS, the following script is not functioning in desired way. sort -t\| -u +6 -7 +12 -14 textfile1.out > \ textfile2uniq.out The -u is fetching unique records differently on SunOS and MP RAS Pentium IV. And thus the records... (1 Reply)
Discussion started by: RRVARMA
1 Replies

4. Solaris

SunOS 5.8 sftp-BatchMode Problem

Hi Gurus I have to connect from a SunOS 5.10 to a 5.8 using sftp in BatchMode. For this, I have generated a Public-Key (ssh-keygen -b 1024 -P "" -t dsa) on the 5.10 and saved it in ~remote-user/.ssh/authorized-keys on the 5.8. Then, running either one of ssh or sftp, it asks for the... (0 Replies)
Discussion started by: unilover
0 Replies

5. Shell Programming and Scripting

sorting data using array in ksh

plz help me..........i have a ksh script that sorts data in ascending order. the 1st half is correct,but for the line no 31 its showing problem 1 #!/bin/ksh 2 3 4 5 echo "Enter the array length" 6 read num 7 8 9 echo "enter the... (4 Replies)
Discussion started by: ali560045
4 Replies

6. UNIX for Dummies Questions & Answers

Sorting problem

Hai , In unix we are going to sort it out all the directories and files based on size of the file. For that we have to use this command ls -al | sort +4nr. If we are giving this command means it will show all the records in a descending order....when I am checking one file bytes its... (4 Replies)
Discussion started by: cool4naren
4 Replies

7. Shell Programming and Scripting

invoke ksh in SunOS 5.7

Hi I have the following in .kshrc file set -o allexport HOSTNAME=$(uname -n) HISTSIZE=50 EDITOR=vi ENV=$HOME/.kshrc PATH=$HOME/bin:/usr/bin:/usr/local:/etc/bin/:/bin:/usr/local/bin:. bind =complete set +o allexport clear and I have the following in .profile umask 077... (2 Replies)
Discussion started by: muru
2 Replies

8. Solaris

Problem in SunOS 5.9

In Solaris (SunOS 5.9) a problem is encountered as : The patch command doesnt patch a file greater than or equal to 1MB after it is deleted or changed. Could anyone know the reason. Is this problem related to patch or Sun OS. If so what may be the solution. (3 Replies)
Discussion started by: SankarV
3 Replies

9. UNIX for Advanced & Expert Users

Migration of binary file from Sunos 5.8 to Sunos 5.9

I have compiled binary file using "cc" on SunOS 5.8 and the same binary file i have copied to SunOS 5.9 and it is giving me core dump error.I want to know whether migration of compiled code from lower version to higer version created this problem. how can i solve this problem.I am pasting the core... (1 Reply)
Discussion started by: Arvind Maurya
1 Replies

10. UNIX for Advanced & Expert Users

Telnet Problem with Solaris (SunOS 5.7)

Hi, I have been facing a telnet problem with our SunOS 5.7 box. Initially we were facing porblems in login both from the console as well as through telnet. The machine was hard-booted after which login from console is possible, but telnet connection is not. The error that is displayed is... (1 Reply)
Discussion started by: manoj_gopal
1 Replies
Login or Register to Ask a Question