Help in conversion ......

Hi,

I have a requirement to capture file time stamp and compare with current system time. I am using HP-AUX K-shell.

Below is what i have done

Getting current date into myfile2
---------------------------------

date +%Y%m%d%H%M%S > myfile2
20091110132800

Getting the file date into myfile
---------------------------------

ls -l request.txt | cut -c46-58 > myfile
Nov 10 09:00

Now how can i transform date format in "myfile" to 20091110132800

Please help

Do you have the -r option in date ? Try if this works :

date -r "request.txt" +%Y%m%d%H%M%S

Not working

date -r "request.txt" +%Y%m%d%H%M%S

date: illegal option -- r
Usage: date [-u] [+format]
       date [-u] [mmddhhmm[[cc]yy]]
       date [-a [-]sss.fff]

I am using HP-AUX K-shell

The -r option for date is only available with GNU date, which is not the default on HP-UX (regardless of the shell)

Could you please suggest the command that will be useful in HP-AUX K-shell

Too complicated, why you don't get the file time from stat ?

stat -t %Y%m%d%H%M%S file | awk '{gsub("\"","");print $10}'

Works for me on BSD :wink: