Please help the newbie....


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Please help the newbie....
# 1  
Old 12-28-2005
Please help the newbie....

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.

Thank you,
Joe
# 2  
Old 12-28-2005
You can write a shell script and add it to the crontab.
# 3  
Old 12-28-2005
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.

Thanks,
Joe
# 4  
Old 12-28-2005
I almost have this I think. Just a little bit more knowledge and I will have it. I found this:

find /{starting directory} -type d -ls > snapshot.txt

where {starting directory} is the path where I want to start spidering from. This output some stuff I recognize and some I do not.

19703248369774140 0 drwx------ 2 Administrators ???????? 0 Sep 15 2003 /c:/Documents\

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!

Thank you in advance.
Joe
# 5  
Old 12-28-2005
OK, I'm even closer now:

I figured this out on my own:

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?

Thanks,
Joe
# 6  
Old 12-28-2005
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.
# 7  
Old 12-29-2005
Thanks. I'm getting so close. Is there a way to combine the 'find' and the 'stat' commands?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl newbie . &&..programming newbie

Hi, I am new to programming and also to perl..But i know 'perl' can come to my rescue, But I am stuck at many places and need help..any small help is much appreciated... below is the description of what i intend to acheive with my script. I have a files named in this format... (13 Replies)
Discussion started by: xytiz
13 Replies

2. Shell Programming and Scripting

perl newbie . &&..programming newbie (question 2)

Hello everyone, I am having to do a lot of perl scripting these days and I am learning a lot. I have this problem I want to move files from a folder and all its sub folders to one parent folder, they are all .gz files.. there is folder1\folder2\*.gz and there are about 50 folders... (1 Reply)
Discussion started by: xytiz
1 Replies

3. UNIX for Dummies Questions & Answers

UNIX newbie NEWBIE question!

Hello everyone, Just started UNIX today! In our school we use solaris. I just want to know how do I setup Solaris 10 not the GUI one, the one where you have to type the commands like ECHO, ls, pwd, etc... I have windows xp and I also have vmware. I hope I am not missing anything! :p (4 Replies)
Discussion started by: Hanamachi
4 Replies

4. Solaris

Newbie

Hello Guys, I just join the unix world today, I had my first lesson on unix today. So expect so much questions from me the next time I log in. Thanks (3 Replies)
Discussion started by: Micko
3 Replies

5. UNIX for Dummies Questions & Answers

Newbie in need of help

Hey all. I am a MS person that is looking to get into real computing for a change. I have seen a few different references to "UNIX Essentials and Core" DVD in different newbie threads and a quick intraweb search on Google only comes up with links to this forum and an Amazon review. Does anyone... (3 Replies)
Discussion started by: cfjohnsn
3 Replies

6. UNIX Desktop Questions & Answers

newbie

Hi, I am interested in learning unix and would like some advice on how I would start to learn unix. Therefore, What would be a good (free) unix distribution to install? Would it be better to invest in a packaged Linux distribution (redhat etc) and get the feel for unix this way? Are... (4 Replies)
Discussion started by: wolf2
4 Replies

7. UNIX for Dummies Questions & Answers

Newbie

I know I'm jsut a newbie, I'm setting up a 1.3 ghz dell as a server. I have experiance using Windows for a webserver, and I was jsut woundering if I would have great difficulty using Unix. is there there like netscape for internet? is there like word? can you listen to Mp3s? can someone... (4 Replies)
Discussion started by: Special K
4 Replies

8. UNIX for Dummies Questions & Answers

newbie needs help

hi i need some help on command grep and pipe but the man grep and man pipe doesn't help me much is there any site show more detail help on all the unix command?? (1 Reply)
Discussion started by: goodman
1 Replies

9. Programming

help<newbie>

i am new to the programing enviroment i know html and some of cgi i would like to know how to creat programs i know nothing!!!!!!!!!!!!! what do i need to get started where can i learn the language what language do i need to learn i tried scheme http://www.htdp.com it did not work out well... (9 Replies)
Discussion started by: skistar
9 Replies

10. IP Networking

help<newbie>

hello i would like to get a server so i may post websites on the web do i have to pay a lot of money to use someone else's server or is there a way to turn a computer into a basic server please help i am trying to find the most inexpensive way to get my own domain up on the web if this is... (1 Reply)
Discussion started by: skistar
1 Replies
Login or Register to Ask a Question