I'm trying to use a regular expression to parse a log file generated from a dir
command from PSFTP.
Example Dir example 1
drwxr-xr-x 1 0 0 0 Jun 21 13:13 .
drwxr-xr-x 1 0 0 0 Jun 21 13:13 ..
-rw-r--r-- 1 0 0 897 Jun 20 15:02 EQA.txt
-rw-r--r-- 1 0 0 897 Jun 20 15:06 EQA1.txt
-rw-r--r-- 1 0 0 897 Jun 16 20:41 Test.txt
-rw-r--r-- 1 0 0 897 Jun 16 21:46 Test1.txt
-rw-r--r-- 1 0 0 897 Jun 21 13:13 Test4.txt
-rw-r--r-- 1 0 0 913 May 31 18:01 test.123456789.txt
psftp> bye
Example Dir example 2
drwx------ 2 MikePC-apps users 4096 Apr 5 2016 .
drwx------ 4 MikePC-apps users 4096 Jan 20 2016 ..
-rw-r--r-- 1 MikePC-apps users 82 Apr 5 2016 test.txt.$01
-rw-r--r-- 1 MikePC-apps users 82 Aug 10 2016 test.txt.$02
-rw-r--r-- 1 MikePC-apps users 82 Aug 10 2016 test.txt.asc
-rw-r--r-- 1 MikePC-apps users 82 Aug 10 2016 test1.txt.$01
-rw-r--r-- 1 MikePC-apps users 1927 Apr 4 2016 test.zip
So from what I found around the net, if a file is older than 6 months or in the future, the year is displayed instead of time in the day.
For example 1, I'm using a regex :/d/d/s .*.*.*
followed by substring function to retrieve file names.
But I don't know how to approach the second example. I was hoping maybe there's a parameter for dir
command to include the time stamp so I can use the same regex. Or maybe there is another regular expression that can handle both examples.
Many thanks!