Sponsor for PC Pals Forum

Author Topic: Making a list.  (Read 2719 times)

Offline Reno

  • Established Member
  • ****
  • Posts: 1294
  • bob
Making a list.
« on: December 19, 2007, 22:36 »
You wouldn't think making a list would be that difficult. I have a ton of html files which all have specific lines of text that I want put one after the other in a big list in one separate text file. I know how to program to a certain level in java and php, but I don't know how to open separate files for manipulation like this. Does anyone have any suggestions on what direction I should take?

Offline Reno

  • Established Member
  • ****
  • Posts: 1294
  • bob
Re: Making a list.
« Reply #1 on: December 19, 2007, 23:43 »
I found how to open, close, and modify files. It shouldn't take me long to come up with some code that will create my list. But since I'm doing it in php I don't think it will work without a server and browser to execute it.

Offline sam

  • Administrator
  • *****
  • Posts: 19413
Re: Making a list.
« Reply #2 on: December 20, 2007, 09:29 »
do you have to do it in php or java? surely the best option would be to use grep or awk
- sam | @starrydude --



Offline Reno

  • Established Member
  • ****
  • Posts: 1294
  • bob
Re: Making a list.
« Reply #3 on: December 20, 2007, 19:54 »
do you have to do it in php or java? surely the best option would be to use grep or awk

No i guess I don't, but then again i've never heard of grep or awk.  ???
« Last Edit: December 20, 2007, 20:00 by Reno »

Offline sam

  • Administrator
  • *****
  • Posts: 19413
Re: Making a list.
« Reply #4 on: December 20, 2007, 21:34 »
oh - grep (http://en.wikipedia.org/wiki/Grep) and awk (http://www.gnu.org/software/gawk/manual/gawk.html) are normal linux tasks -  sorry I was assuming that you were using a linux webserver.

With PHP I guess you could just open the file using php include and only include the line you are after, but I'm not entirely sure - thinking about it - what you want to do.
- sam | @starrydude --



Offline Reno

  • Established Member
  • ****
  • Posts: 1294
  • bob
Re: Making a list.
« Reply #5 on: December 21, 2007, 00:08 »
Yeah, i run apache on windows.

I have a ton of html files. In these files There are descriptions of directories and files listed between unique tags. What I want to do is list these descriptions in a htaccess file. It would take hours to do it by hand and I was wanting to automate it.

Offline Reno

  • Established Member
  • ****
  • Posts: 1294
  • bob
Re: Making a list.
« Reply #6 on: December 21, 2007, 00:47 »
Grep was pretty simple to understand, but it doesn't appear to be able to do what I need. I installed gwak for windows and was utterly confused from the word go.

Offline sam

  • Administrator
  • *****
  • Posts: 19413
Re: Making a list.
« Reply #7 on: December 21, 2007, 08:18 »
hmmm, awk is a bit more confusing and I prefer to use grep - with grep you should be able to search for a string and return the line - but you might need todo it multiple times piping the info into the next grep task. Something like:

Code: [Select]
grep -A 1 "Search" results.txt > output.txt
but it does depend on how sophisticated your html file is - and once you have done it once you would have to loop over this in the terminal but I'm not sure how todo that in windows.
- sam | @starrydude --



Offline Reno

  • Established Member
  • ****
  • Posts: 1294
  • bob
Re: Making a list.
« Reply #8 on: December 21, 2007, 08:38 »
I got awk opened up in dos. What I don't understand is if I run awk code plus the file name won't that only do one file at a time? How would I arrange it to search through a directory of files? Also, how would I sort the code to output the results into another text file?

Offline sam

  • Administrator
  • *****
  • Posts: 19413
Re: Making a list.
« Reply #9 on: December 21, 2007, 16:04 »
ok this is the problem with using dos, which is why this is probably not the best of solutions and it will probably be best todo in a different way - not sure how though.

At first I was thinking you were using linux and to output to a file you literally just pipe ">" the output to the file of your choice. Also if you are using a normal shell you could simply write a script to loop over all the html files in a directory. Not sure how todo this in DOS at all.

Thinking about this you can probably do all this in perl, I'll have a think.

I found what looks like a useful page on DOS scripting - http://www.ericphelps.com/batch/  and this one doesnt look too bad http://kh.hd.uib.no/httpddoc/setup/scripts/basic.htm

- sam | @starrydude --




Show unread posts since last visit.
Sponsor for PC Pals Forum