homepage Welcome to WebmasterWorld Guest from 174.129.130.202
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
Using "ls" to list all html files recursively...
How to please ;-)
Nick_W




msg:909996
 6:07 pm on Sep 3, 2002 (gmt 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

 

PaulPaul




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

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

littleman




msg:909998
 7:12 pm on Sep 3, 2002 (gmt 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

Nick_W




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

What's the .-name bit?

I'm just getting a bunch of errors?

Nick

littleman




msg:910000
 7:25 pm on Sep 3, 2002 (gmt 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.

Nick_W




msg:910001
 7:29 pm on Sep 3, 2002 (gmt 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

Duckula




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

it wasn't

¶ grep -c

it was

¶ grep -c .

with the trailing dot.

And

¦ wc -l

would do the same thing

Nick_W




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

Ahhhhhh!

My eyes arn't the best ;)

Nick

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved