For ls command,-r option is not working on OSF1


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users For ls command,-r option is not working on OSF1
# 1  
Old 03-27-2007
Question For ls command,-r option is not working on OSF1

There r 2 servers. Lets call them S1 and S2..

S1 is OSF1 and S2 is SunOS..

One directory of S2 is mounted on S1. say abc/xyz

There is one application which continuously put xml files in that directory (on S2).

If we give command “ls -lrt” on S2 it gives proper output.. (i.e. gives list of all files, sorted on time with reverse order)

But if we give same command on S1, it doesn't work. (coz this one is lowest version of UNIX).



We have shell script which runs on S1. which takes these files, reads it and stores data into oracle. Everything is running fine.

But we need to process all the files in sequence. For that we need to list out all those files in sorted order of time...


below is the command which we are using to get files listed in FIFO manner, when tried to run on OSF1:
These files are created at the same time. FILE_WOIR.7229373.txt is oldest file and FILE_WOC.7229343.txt is latest among the listed below.

S1> ls -lt
-rw-r--r-- 1 3130 10 68 Mar 26 11:45 FILE_WOC.7229343.txt
-rw-r--r-- 1 3130 10 68 Mar 26 11:45 FILE_WOC.7229349.txt
-rw-r--r-- 1 3130 10 68 Mar 26 11:45 FILE_WOC.7229369.txt
-rw-r--r-- 1 3130 10 69 Mar 26 11:45 FILE_WOIR.7229345.txt
-rw-r--r-- 1 3130 10 69 Mar 26 11:45 FILE_WOIR.7229351.txt
-rw-r--r-- 1 3130 10 69 Mar 26 11:45 FILE_WOIR.7229373.txt

Now after using -r option which means " Reverses the order of the sort, giving reverse collation or the oldest first, as appropriate."
But which is not the fact.

S1> ls -lrt
-rw-r--r-- 1 3130 10 68 Mar 26 11:45 FILE_WOC.7229343.txt
-rw-r--r-- 1 3130 10 68 Mar 26 11:45 FILE_WOC.7229349.txt
-rw-r--r-- 1 3130 10 68 Mar 26 11:45 FILE_WOC.7229369.txt
-rw-r--r-- 1 3130 10 69 Mar 26 11:45 FILE_WOIR.7229345.txt
-rw-r--r-- 1 3130 10 69 Mar 26 11:45 FILE_WOIR.7229351.txt
-rw-r--r-- 1 3130 10 69 Mar 26 11:45 FILE_WOIR.7229373.txt

Strangely after aplying the option -r, output doesnt differ, it remains same. We tried using many options to get oldest file first and latest as last but invain, the output remains same.


Where as when we check output of same command from Sun OS system, it gives actual output, which is in FIFO manner.

S2>ls -lt
-rw-r--r-- 1 S2 staff 68 Mar 26 11:45 FILE_WOC.7229343.txt
-rw-r--r-- 1 S2 staff 68 Mar 26 11:45 FILE_WOC.7229349.txt
-rw-r--r-- 1 S2 staff 68 Mar 26 11:45 FILE_WOC.7229369.txt
-rw-r--r-- 1 S2 staff 69 Mar 26 11:45 FILE_WOIR.7229345.txt
-rw-r--r-- 1 S2 staff 69 Mar 26 11:45 FILE_WOIR.7229351.txt
-rw-r--r-- 1 S2 staff 69 Mar 26 11:45 FILE_WOIR.7229373.txt

After applying the option -r, it reverses the order i.e. oldest comes first and latest goes down.

S2>ls -lrt
-rw-r--r-- 1 S2 staff 69 Mar 26 11:45 FILE_WOIR.7229373.txt
-rw-r--r-- 1 S2 staff 69 Mar 26 11:45 FILE_WOIR.7229351.txt
-rw-r--r-- 1 S2 staff 69 Mar 26 11:45 FILE_WOIR.7229345.txt
-rw-r--r-- 1 S2 staff 68 Mar 26 11:45 FILE_WOC.7229369.txt
-rw-r--r-- 1 S2 staff 68 Mar 26 11:45 FILE_WOC.7229349.txt
-rw-r--r-- 1 S2 staff 68 Mar 26 11:45 FILE_WOC.7229343.txt

We want the output to behave ideally as on SUN OS, when the order is reversed.

Is there any solution for this?

Last edited by asmita; 03-27-2007 at 04:06 AM.. Reason: To add example
# 2  
Old 04-16-2007
sort sequence

The ls command is probably using a binary sort to change the order, and the mtime on the file is same (to the nearest second), so that the sort program sees them as equal and does not necessarily retain the original sequence.
The files in your example appear to have file names generated chronologically.
Why not use 'ls' to create a file and then 'sort' the file using '.' as a delimiter and sort on the middle field, or sort on the first field first, and then the second field.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Maxdepth option of find command not working

Can you please figure out what is the issue here $ find . -maxdepth 1 -type f -size 0 -print find: bad option -maxdepth please find the OS details $ uname -a HP-UX g5u1216 B.11.31 U ia64 2614088426 unlimited-user license Use code tags, thanks. (6 Replies)
Discussion started by: TomG
6 Replies

2. AIX

SQLPLUS -S option not working

Hi All, I am using the following script to run some sql on database but i am not getting the result. When i tried the same by removing "-s" option it is working fine but getting other things as well with my input as shown below. Can anyone please suggest why "-s" option is not working in AIX and... (2 Replies)
Discussion started by: ssk250
2 Replies

3. Shell Programming and Scripting

-v and -f option for grep not working

In solaris, i m trying to find the files having a particulat extension and then from the list i want to exclude those files which is present in a file. But it seems the -f and -v option are not working find $source -type f -name $extn | /usr/xpg4/bin/grep -F -v -f $exclude | while read... (7 Replies)
Discussion started by: millan
7 Replies

4. UNIX for Dummies Questions & Answers

~c is not working properly with -r option

Hi There, --------- file1 ------- ~c asd@ac.com -------------- Now i am using below command cat file1|mailx -s " testing" -r " My Name" abc@tech.com (3 Replies)
Discussion started by: Tapan Sharma
3 Replies

5. Shell Programming and Scripting

daystart option not working in find command

Hi, I am trying to list all the files created / modified today in a directory. With reference to this thread, https://www.unix.com/shell-programming-scripting/20324-capture-all-today-files.html I have used the below command to list all the files modified today. find . -daystart -type f... (8 Replies)
Discussion started by: arunkumarmc
8 Replies

6. HP-UX

who command option not working

Running HP 11.31 on a HP3600. But when I log in as a user the who command works but if I use an option like "who -m" I get nothing. Any thoughts on what is causing this problem. (11 Replies)
Discussion started by: KMRWHUNTER
11 Replies

7. Shell Programming and Scripting

sub option of awk command not working with "\" character.

Hi all, I would like to replace some string in a text file by some string which would contains special characters like "/","\". I.e. I have a text file with the statement contactperson somewhere in it. Now I want to replace it by something else which includes special characters like "/","\" ... (1 Reply)
Discussion started by: shareef
1 Replies

8. UNIX for Advanced & Expert Users

Segmentation fault , OSF1/TRU64

hi, i am running a process on a unix machine (OSF1 inca V5.1 2650 alpha) which is doing some operations on an oracle database. somehow this process is going down and produces coredump about 2-4 times in a day. after restarting, it continue running without a problem, then after sometime... (3 Replies)
Discussion started by: yakari
3 Replies

9. UNIX for Dummies Questions & Answers

-d option not working...

:confused: In the following, when I enter a valid, existing directory,why am I getting Not Found when the Dir DOES exist? read auser echo "You entered $auser" wait 2 cd /home if then echo "Dir Exists" sleep 2 else echo "/home/$auser Not Found" sleep... (2 Replies)
Discussion started by: rgouette
2 Replies

10. Solaris

Why does the 'ps' command with -u option not working?

How can I use the 'ps' command to view current sessions but only for a given process/user, with the -u parm? In older versions of Unix, this used to work, but not in Sun Solaris. Thanks (4 Replies)
Discussion started by: ElCaito
4 Replies
Login or Register to Ask a Question