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 have edited the output of the above find command to a file that has lines that look like this:
First off, your estimation about sed being the right tool is correct. It was written with problems like yours in mind.
BUT: i don't think your are on the right track. The reason is: you create a sort of list and this list is almost correct - almost, but not quite so. Now you want to patch this almost-correct list into something which is indeed correct. The problem is: when you are writing software it is most of the times advisable to do it correctly the first time instead of doing it almost correctly and then patch it.
Instead of creating an sed-script to "patch the list to work" create the list correctly immediately. This is easily possible.
You mention an "above find command", but i cannot find that. So: why don't you put your script so far here and we help you to create not an amost-correct but a correct list.
Btw., i have a suspicion that your find-command (if you have used that alone) will not be giving the correct result either because i don't know of any way to solve your problem (even to the almost-correct state you have) with "find" alone - this would be a rather non-trivial task if it could be done at all (and i suspect it is impossible). This also could be corrected if you provide your work so far.
The find command is just giving me the path of the user who's index.html is edited, and I am trying to transform that into the links I stated above. My problem is that the users name is only listed once in the path and when I am using sed I do not know how to copy just their user name(lengths varying) to be used twice in the same line.
Ok, this is about the script i expected. It has several problems, but first, lets analyze your problem correctly. Software engineering (and script programming is a form of software engineering) is about correctly analyzing the problem before you envision a solution.
Your "find" command compares dates - the date/time the file local.cshrc has been changed to when the file index.html in the users home directory. If a new user is created after the last change of the skeleton file his file ~/index.html will be newer regardless of being changed or not. On the other hand if the skeleton file is changed even the files reported as changed before will be reported as not changed. So you don't find the correct files in first place.
Lets see: when a new user is created s/he is delivered some standard version of index.html. If s/he changes it it will differ from this standard file, if not then not. Now this is indeed a criterion which will pick out the right files, yes?
So, your task is to find a unix utility which compares two files and finds out if they differ or not. If there is such an utility we could write the following program (in pseudocode):
There are two things you can do for now:
1) find a way to get all the users names. (You will need this to set up the while-loop above.) I could tell you, but i don't want to spoil your fun finding it out.
2) find a unix command which compares two files and finds out if they are equal (you will need this for deciding the if-construction).
Report back here with your answers and i will give you the directions for the next stage.
Sorry for dragging this out this way, but i cannot give you enough directions at once without giving away the solution. As the spirit of this board is to help you learn and not spoon-feed you solutions we have to do it this way. As i am convinced you will soon find out Unix is not only a lot of fun to work with but also a lot of fun to learn about, so enjoy it while the learning experience lasts.
Thanks alot, and I would much rather learn myself than be spoon fed since I like this kind of stuff. Thanks again and I will see what I can do.
---------- Post updated at 07:19 PM ---------- Previous update was at 07:01 PM ----------
Ok im already having trouble. I can create a file that lists all the users; I know that I should use cmp to tell if the files are the same, but I do not know how to set up the while loop take each username in the file and then use it in the iff statement. I know I have to use a variable, but how do I get the while loop to transverse the file line by line?
I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: -->
cat comp.pkglist
Package list: nss-util-devel-3.28.4-1.el6_9.x86_64
Version Change: 3.28.4 -->... (1 Reply)
Sorry for the long/weird title but I'm stuck on a problem I have. I have this XML file:
</member>
<member>
<name>TransactionID</name>
<value><string>123456789123456</string></value>
</member>
<member>
<name>Number</name>
... (9 Replies)
Dear All,
Can anyone help to remove the , bewteen "" in a string by using sed or awk?
e.g.
input : 1,4,5,"abcdef","we,are,here",4,"help hep"
output:1,4,5,"abcdef","wearehere",4,"help hep"
Thanks,
Mimi (5 Replies)
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
HI All,
I am new to unix. I have a file would like to do some editing by using awk, cut and sed. Could anyone help?
This file contain 100 lines. There are one line for example:
2,"102343454",5060,"579668","579668","579668","SIP",,,"825922","035885221283026",1,268,"00:59:00.782 APR 17... (2 Replies)
Hi all,
I have a list that I would like to parse with awk/sed. The list is contains entries such as:
JournalTitle: Biochemistry
JournalTitle: Biochemistry and cell biology = Biochimie et biologie cellulaire
JournalTitle: Biochemistry and experimental biology
JournalTitle: Biochemistry and... (6 Replies)
Hello,
i have a file, i open the file and read the line, i want to get the first item in the csv file and also teh third+6 item and wirte it to a new csv file. only problem is that using echo it takes TOO LONG:
please help a newbie. below is my code:
WorkingDir=$1
FileName=`cut -d ',' -f... (2 Replies)
Hi all
I use aix (sadly).
I've got a file consisting of fields separated by commas, I need a sed or awk command that will delete all spaces between two commas as long as there are only spaces between the commas.
eg
,abc, ,sd , ,dr at
would become
,abc,,sd ,,dr at
I have... (53 Replies)
Hi!
I am writing a script handling downloading list of files and I have to check whether file is present locally and if not finished than continue downloading. To do so I have to compare sizes of remote file and local file.
To check remote file size I have to parse something like this:
... (2 Replies)
Hello Awk Gurus,
Can anyone of you help me with the below problem. I have got a file having data in below format
pmFaultyTransportBlocks
-----------------------
9842993
pmFrmNoOfDiscRachFrames
-----------------------
NULL
pmNoRecRandomAccSuccess
-----------------------... (4 Replies)