I am very new to UNIX, but just playing around with cygwin, I can see that it will work nicely for a project I'm working on. Starting from any given directory, I want my app to spider and collect every filename, size, full path, created date, modified date and last accessed date and save this data in a text file. Yes, this is a server snapshot app to see if changes are made to a production server or if a QA server matches a test server, etc...
I wrote this in VB and although it worked great, it is very slow and if there are more than 100,000 files (which there frequently is) the program will crash or hang.
Can anyone get me started on how write a batch that I can kick off every night and it will do the process noted above and save it to any delimted type file?
I think I can write the batch code if I knew what commands would do what I need here.
I can do the script, but I'm not sure what UNIX commands to use. I need something that will do a directory spider or directory tree. I know you can output almost any UNIX command to a file, so I just need to know which commands will return the filenames, full path, size, created date, last accessed date and modified date.
This (above) is a sample line. It imports into Excel real well with Space delimiter.
Now if I can tweak the above line to give me the filenames, and two other date and time stamps. I'm not sure what date is returned here, but I need Created, Modified and Accessed.
I believe the long number is the size in bits? Correct?
By the way, in cygwin, this took about 40 seconds to output over 8000 items. I'm very impressed. UNIX rocks!
find /{starting directory} -type f -ls > snapshot.txt
gives me the filenames.
If you could only see the VB source code that I wrote to get the same results as this one UNIX command line. Not to mention how slow VB is. Yikes! That is scary!
Can anyone tell me how to get modified date, created date and last accessed date? Also, is that huge number the file size?
Yes, the big number in the 5th (or so) field of the ls -l output is the file size. It gives you the modified date. I'm not sure that you can get the created or last accessed date from ls.