I am trying to write a small code where i capture the output of ls command on a remote system.
However i want a certain consistency in the date format being received
Say i want it to be dd/mm/yyyy format.
how can i do this?
This is what i am doing currently
FTP1=`ssh ${USER_FTP_origin}@${MACHINE_FTP_origin} 2> /dev/null << !
cd ${PATH_ORIGIN}
ls -1 $File_name
exit
!`
This however sometimes gives me the date in dd/mm/yyyy and sometimes in mm/dd/yyyy format.
Please suggest what can be done
Please can you post one example of each of the different "ls" formats you have seen, stating which Operating System was involved in each and every case. Please create the examples on the same day when dd != mm.
Translating timestamps from "ls -la" to numeric date format has been covered extensively on this site. If there is a small variety of formats to deal with why not create a flag file on each computer which you can read in your script.
If you are the administrator of these machines you could use "C" programming language to get stat (man 2 stat) information in a consistent format across a wide variety of platfoms.