The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers > Homework & Coursework Questions
.
grep unix.com with google



Homework & Coursework Questions Students must use and complete the template provided. If you don't, your post may be deleted! Special homework rules apply here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-09-2009
Registered User
 

Join Date: Nov 2009
Posts: 10
Searching Through File System using find -newer

1. The problem statement, all variables and given/known data:

Problem Statement for project:

When an account is created on the CS Unix network, a
public html directory is created in the account’s home directory. A default web page is put into that directory.


Some users replace or edit the default page, while others do not. We would like to add a new link from the department web page to another page which lists all students who have changed their web page from the default. We don’t want to track these things by hand, and we want the list to be automatically updated every night at 3:00AM.



You are to write a script that will
1. find all users who are students and who have changed their web page from the default that
was provided when their account was created,
2. generate an HTML file named student web pages.html which contains a nicely formatted list of links to each student web page that you found,
3. copy that file into a directory specified on the command line, and


4. make sure that anyone can read it.

My Problem:
I do not have a problem with this project just a single aspect for searching through the file system using find -newer. My problem is how to get the -newer file to be within the same users path that the find command is already transversing through. My attempts are below. Any help would be great. Thanks.



2. Relevant commands, code, scripts, algorithms:

find -newer

3. The attempts at a solution (include all code and scripts):

Here is the command that I am using to transverse the file system:


Code:
$ find ./undergrad[1-5]/*/public_html/index.html


The first * represents a user account within the 5 undergrad directories. I need to figure out how to use -newer to be in the same user account that the above command is in at the time is compares it to the -newer file.

Here is the command that I tried using but I don't think it worked.


Code:
$ find ./undergrad[1-5]/*/public_html/index.html -newer ./*/.profile


I am trying to compare the index.html file of a user to their .profile file so see if it has been modified since the account was created. However, I think that newer is looking at the .profile of any directory from the current directory.

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Texas Tech University
Lubbock TX
USA
Dr. Pyeatt
CS 3352


Thanks for the help.
  #2 (permalink)  
Old 11-10-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
 

Join Date: Dec 2008
Location: .at
Posts: 2,583
Hm, I'd tackle the problem another way. finds -newer option only accepts 1 file as a reference, so you'd have to loop through all user directories, comparing against that users .profile, which is not very efficient. Also, what if a user changed his/her .profile after changing the index.html?

If the public_html directory is created automatically, so is the index.html, and this means there's probably a template (skeleton) for it. diff against that, and you'll get those files that have been changed.
  #3 (permalink)  
Old 11-10-2009
Registered User
 

Join Date: Nov 2009
Posts: 10
ok, that is a much better idea, I forgot that you can change your .profile. But where would that typicaly be loacted on a unix server. Would it a a file that is unique to each user or would it be stored some where else? I tried using find skel from /etc directory and came up with these results:

Code:
$ find skel
skel
skel/.profile
skel/local.cshrc
skel/local.login
skel/local.profile

should I compare to the local.profile or are you saying to find the skel file for the index.html?

---------- Post updated at 10:20 AM ---------- Previous update was at 09:58 AM ----------

Nevermind I used newer against /etc/skel/.profile and it seemed to work. If you still think that I am doing it wrong Please let me know, but Thanks again for the help I was starting to get frustrated with this project.
  #4 (permalink)  
Old 11-10-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
 

Join Date: Dec 2008
Location: .at
Posts: 2,583
I meant the template for the index.html file. The problems if your comparing the time against the /etc/skel/.profile file are
  • Since most users probably were created after this file, all users will appear to have changed their homepage
  • If the administrator changes the skeleton .profile, no user will appear to have changed his homepage
So, if possible, try to find out where the default homepage was copied from, and compare against that content.
  #5 (permalink)  
Old 11-10-2009
Registered User
 

Join Date: Nov 2009
Posts: 10
Ok I will try and find it if I can, and if not I will ask my network admin. Thanks for the help.
  #6 (permalink)  
Old 11-11-2009
Registered User
 

Join Date: Nov 2009
Posts: 10
ok so I relized that we have like 10 unix servers, and each of the files that I am comparing to was created at different times. So I need to find a way to use diff on a know unedited index.html, and get the file path instead of the normal diff out put. Any ideas? thanks
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to script to find the newer date in a text file? boolean2222 Shell Programming and Scripting 6 08-10-2009 04:15 PM
find -cmin or fin -newer xxxyyyy UNIX for Advanced & Expert Users 2 11-18-2008 08:31 AM
Searching the file system LiquidChild UNIX for Dummies Questions & Answers 9 06-01-2007 12:00 PM
Problem with find ! -newer dbfree Shell Programming and Scripting 3 12-19-2005 10:56 PM
searching for a string though file system peter.herlihy UNIX for Dummies Questions & Answers 3 12-06-2001 04:19 AM



All times are GMT -4. The time now is 10:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0