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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting all the html files in a particular directory

Status
Not open for further replies.

thendal

Programmer
Aug 23, 2000
284
Hi all!

I need to grap all the .htm,.html files from a particular directory including its subdirectory ..for example

/home/httpd/project1

mean it need to bring all the files from project 1 and its subdirectories.the list should be look like this ...

/home/httpd/project1/test.htm
/home/httpd/project1/dir1/test1.html
/home/httpd/project1/dir1/dir2/test2.htm

how i can do this ...

ThanX
:)

 
You would use the -r option with cp. For example:

cp -r source-dir/*.htm* /destination-dir

This would copy everything in the source directory named *.htm* to the destination directory. All sub-directories of the source dir would be copied recursively.
 
Thanks Rhythmace ...But i just need the loaction of all the html pages ...
actually i need to replace a particular content in all the html pages to another content ie)

using perl script i will read all the html file and replace with particular content ..but my first task is to find all
the html file locations in the specified directories and sub directories ....

i think we need to use some think like

find file extension (.html ) the give directory path

I hope i have conveyed what i need...

Thanks again
:)
 
OK, now I can dig where you're coming from. :eek:) how 'bout if you use "find" something like this:

find / -name *.htm? -fprint outfile.txt

This will find every match for htm and html under the root "/" directory and subs. The -fprint tells find to print the output to a file called outfile.txt rather than the standard output (screen). You should be able to pass this file to grep or your script. It will contain all the file names and paths.
 
You got it...
Thank you very much Rhythmace ..

:)

 
Dude:-

I tried it but its giving me an error

in solaris its giving an error

find: bad option test.html
find: path-list predicate-list

in irix

Missing conjuction

did u try it on your machine

Thanks again
:)
 
Don't be foolish. Of cource I tested it. :eek:) Did ya type it just like I had it? This is how that command line breaks down:

find (I wanna "find" something)
/ (where in the dir tree you want to start looking)
-name (I'm looking for a file name not size or date etc.)
*.htm? (the pattern to match i.e. any file where the extension starts with htm)
-fprint (I want the results sent to a file)
outfile.txt ( this is the name I want for that file)

The syntax may be a little different on solaris so you might want to check your man pages. (man find)



 
Hi,

From memory, on Solaris you would have to do it more like this

find /home/http/project1 -name "*.htm*" -print) > outfile.txt

(I don't think you can use fprint)

Regards
 
Gotcha ...It worked ..thanks

ifincham is right fprint didn't work in solaris ...

and also the only part i missed in the rhythmace find command is double quotes ..find / -name "*.htm?" -print > outfile.txt..

but with double quote it worked perfectly fine ..

Thanks both of you ...

:cool:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top