The output of "ls -l" is not uniform in that it displays time differently (including years) depending on whether the file is older than 6 months or not. Even they are all younger than 6 month, you have to take into consideration that December is older than February when the current date is January. Not sure if the output of ls from ftp behave the same way.
Not very elegant but it works, using GNU date to make sense of the different dates with year/month/day or month/day/time (IMO sort -M is not accurate in this case as it does not take into account year dates).
I list files on server ftp and, it gives me a list of file in alphabetic order.
I want this list of file in order like "ls -t", the niewer in first and the older last.
INPUT:
drwxr-x--- 2 ftp_mont System 0 Sep 30 09:16 .
drwxr-x--- 2 ftp_mont System 0 Jul 15 2009 ..
-rwxr-x--- 1 ftp_mont System 250324761 Sep 27 15:47 Dossier_secheresse-H264-1.mov
-rwxr-x--- 1 ftp_mont System 343998791 Sep 30 09:20 manif laitiers-H264.mov
-rwxr-x--- 1 ftp_mont System 169097455 Sep 27 15:55 Mende_Mende-H264.mov
-rwxr-x--- 1 ftp_mont System 12063097 Sep 27 15:32 Mende_Mende_ITW.mov
OUTPUT:
-rwxr-x--- 1 ftp_mont System 343998791 Sep 30 09:20 manif laitiers-H264.mov
-rwxr-x--- 1 ftp_mont System 169097455 Sep 27 15:55 Mende_Mende-H264.mov
-rwxr-x--- 1 ftp_mont System 250324761 Sep 27 15:47 Dossier_secheresse-H264-1.mov
-rwxr-x--- 1 ftp_mont System 12063097 Sep 27 15:32 Mende_Mende_ITW.mov
I want to do this because i get file by mirroring with wget and wget have a problem with the files with accent...
I thank to rename the file downloaded by wget with the list of file on server then i have 1 file text where have the file in order "by time"
let i=0;for file in /Users/macbook/oberon/*;do echo "$file";let i=i+1;var="$(cat $temp/oberon_trie.txt | sed 's/ *$//g' | sed -n "$i"p)";mv "$file" "/Users/macbook/oberon/$var";done