Welcome to WebmasterWorld Guest from 184.72.177.182

Forum Moderators: bakedjake

Message Too Old, No Replies

Using "ls" to list all html files recursively...

How to please ;-)

     
6:07 pm on Sep 3, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 4, 2002
posts:5044
votes: 0


Hi all,

I have a directory with many sub-dirs.

I would like to ls all files ending in .html recursively.

I've tried


$> ls -R /path/to/dir/*.html

but it only lists from the parent dir not recursively through all the sub-dirs....

Any clues greatly appreciated ;)

<added>
Also I'd like to count these files...
</added>

Nick

6:48 pm on Sept 3, 2002 (gmt 0)

Junior Member

10+ Year Member

joined:July 24, 2002
posts:135
votes: 0


I havenít used UNIX for a while, but I believe I used the find command for that type of task.
7:12 pm on Sept 3, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member littleman is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:June 17, 2000
posts:2924
votes: 0


There might be a cleaner way but this will work from the directory you want to recursively search in.
find . -name "*.html" ¶ grep -c .

added:
If you want a list of them you could do something like this:
find . -name "*.html" > temp.txt

7:19 pm on Sept 3, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 4, 2002
posts:5044
votes: 0


What's the .-name bit?

I'm just getting a bunch of errors?

Nick

7:25 pm on Sept 3, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member littleman is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:June 17, 2000
posts:2924
votes: 0


-name is telling find to look for files with that string in the name.
Make sure you have a space between the "." and -name.
7:29 pm on Sept 3, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 4, 2002
posts:5044
votes: 0


Great, got it. thanks very much ;)

Didnt get ¦ grep -c to work though, I output it and then got a line count in vim...

Nick

7:32 pm on Sept 3, 2002 (gmt 0)

Full Member

10+ Year Member

joined:Mar 14, 2002
posts:325
votes: 0


it wasn't

¶ grep -c

it was

¶ grep -c .

with the trailing dot.

And

¦ wc -l

would do the same thing

7:36 pm on Sept 3, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 4, 2002
posts:5044
votes: 0


Ahhhhhh!

My eyes arn't the best ;)

Nick