Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Routine String Search Options

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello,

I need to routinely look in a fixed set of directories to find if .html files have been updated in the last 30 days. The challenging part of this (to me) is that I need to test for this via the files <meta> tag "pubdate" value then build of list of files that meet this criteria.

Example myfile.html:
Code:
<html>
<head>
	<title></title>
	[b]<meta name="pubdate" content="20041215">[/b]
</head>
<body>
<h1>My File</h1>
</body>
</html>

Any suggestions on tools or code to do this?



Thanks,

Michael42
 
A script could be written to do this... You will need a list of directories... Use ls command to find the .html files... Use grep to fine and display the "meta name" line... Use >> to transfer the line to a file for you to look at.
 
#!/bin/sh
echo "Enter directory to search"
read directory
for i in `find $directory -follow -name *.htm*`
do
grep -i pubdate $i | awk '{print $1}' >> file-list.html
done

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top