Welcome to WebmasterWorld Guest from 54.226.241.8

Forum Moderators: bakedjake

Message Too Old, No Replies

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

How to please ;-)

     

Nick_W

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

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



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

PaulPaul

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

10+ Year Member



I havenít used UNIX for a while, but I believe I used the find command for that type of task.

littleman

7:12 pm on Sep 3, 2002 (gmt 0)

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



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

Nick_W

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

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



What's the .-name bit?

I'm just getting a bunch of errors?

Nick

littleman

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

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



-name is telling find to look for files with that string in the name.
Make sure you have a space between the "." and -name.

Nick_W

7:29 pm on Sep 3, 2002 (gmt 0)

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



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

Duckula

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

10+ Year Member



it wasn't

¶ grep -c

it was

¶ grep -c .

with the trailing dot.

And

¦ wc -l

would do the same thing

Nick_W

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

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



Ahhhhhh!

My eyes arn't the best ;)

Nick

 

Featured Threads

Hot Threads This Week

Hot Threads This Month