Sponsored Content
Full Discussion: recursive wc on a directory?
Top Forums UNIX for Dummies Questions & Answers recursive wc on a directory? Post 302327408 by Scott on Sunday 21st of June 2009 11:51:33 AM
Old 06-21-2009
I ran them lots of times.... but I was running Linux in a VM on Windows. And who knows what that get's up to while you're not looking!

The point is, it seems, trusting that your filenames don't have spaces - and you don't have to check for them, it's quicker than if you do need to check.

In any case, the awk solution was nicer.
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

non recursive search in the current directory only

Hi, Am trying for a script which should delete more than 15 days older files in my current directory.Am using the below piece of code: "find /tmp -type f -name "pattern" -mtime +15 -exec /usr/bin/ls -altr {} \;" "find /tmp -type f -name "pattern" -mtime +15 -exec /usr/bin/rm -f {} \;" ... (9 Replies)
Discussion started by: puppala
9 Replies

2. Programming

recursive copy of the directory

I want to copy a directory recursively ( it again has directories) and the directory is on windows and is nfsmounted in vxWorks, i am using unix to develop the code for this, can any one suggest me how to copy the directories recursively. (7 Replies)
Discussion started by: deepthi.s
7 Replies

3. UNIX for Dummies Questions & Answers

recursive directory listing with ownership

i'm playing around with "ls" and "find" and am trying to get a print out of directories, with full path, (recursive) and their ownership.... without files or package contents (Mac .pkg or .mpkg files). I'd like it simply displayed without much/any extraneous info. everything i've tried, and... (5 Replies)
Discussion started by: alternapop
5 Replies

4. Programming

Recursive remove directory.

What is the best way to completely remove dir with it's content ??? rmdir deletes only EMPTY dirs as i know. The man page of remove function says "remove() deletes a name from the file system." Can it remove any dir recursively ??? :rolleyes: (7 Replies)
Discussion started by: Trump
7 Replies

5. UNIX for Advanced & Expert Users

Recursive directory search using ls instead of find

I was working on a shell script and found that the find command took too long, especially when I had to execute it multiple times. After some thought and research I came up with two functions. fileScan() filescan will cd into a directory and perform any operations you would like from within... (8 Replies)
Discussion started by: newreverie
8 Replies

6. UNIX for Dummies Questions & Answers

recursive copy into a directory and all its subdirectories...

I want to copy a file from the top directory into all the sub-folders and all of the sub-folders of those sub-folder etc. Does anyone have any idea how to do this? Thanks in advance of any help you can give. (3 Replies)
Discussion started by: EinsteinMcfly
3 Replies

7. UNIX for Beginners Questions & Answers

Chattr recursive exclude directory

Attempting to recursive chattr directories while excluding a directory, however the command which works with chown does not seem to with chattr find /mysite/public_html ! -wholename '/mysite/public_html/images' -type d -exec chattr -R +i {} \; find /mysite/public_html -not -path "*/images*"... (2 Replies)
Discussion started by: carnagel
2 Replies
ftw(3)							     Library Functions Manual							    ftw(3)

Name
       ftw - walk a file tree

Syntax
       #include <ftw.h>

       int ftw (path, fn, depth)
       char *path;
       int (*fn) ( );
       int depth;

Description
       The  subroutine	recursively  descends  the  directory  hierarchy rooted in path.  For each object in the hierarchy, calls fn, passing it a
       pointer to a null-terminated character string containing the name of the object, a pointer to a stat structure containing information about
       the object, and an integer.  For further information, see Possible values of the integer, defined in the <ftw.h> header file, are FTW_F for
       a file, FTW_D for a directory, FTW_DNR for a directory that cannot be read, and FTW_NS for an object for which stat could not  successfully
       be  executed.   If the integer is FTW_DNR, descendants of that directory will not be processed.	If the integer is FTW_NS, the the contents
       of the stat structure will be undefined.  An example of an object that would cause FTW_NS to be passed to fn would be a file in a directory
       with read but without execute (search) permission.

       The subroutine visits a directory before visiting any of its descendants.

       The  tree  traversal  continues	until the tree is exhausted, an invocation of fn returns a nonzero value, or some error is detected within
       (such as an I/O error).	If the tree is exhausted, returns zero.  If fn returns a nonzero value, stops its tree traversal and returns what-
       ever value was returned by fn.  If detects an error, it returns -1, and sets the error type in errno.

       The  subroutine uses one file descriptor for each level in the tree.  The depth argument limits the number of file descriptors so used.	If
       depth is zero or negative, the effect is the same as if it were 1.  The depth must not be greater than the number of file descriptors  cur-
       rently available for use.  The subroutine will run more quickly if depth is at least as large as the number of levels in the tree.

Restrictions
       Because is recursive, it is possible for it to terminate with a memory fault when applied to very deep file structures.
       It could be made to run faster and use less storage on deep structures at the cost of considerable complexity.
       The  subroutine	uses to allocate dynamic storage during its operation.	If is forcibly terminated, such as by longjmp being executed by fn
       or an interrupt routine, will not have a chance to free that storage, so it will remain permanently allocated.  A safe way to handle inter-
       rupts is to store the fact that an interrupt has occurred, and arrange to have fn return a nonzero value at its next invocation.

Diagnostics
       [EACCES]       Search permission is denied on a component of path or read permission is denied for path.

       [ENAMETOOLONG] The length of the path string exceeds {PATH_MAX}, or a pathname component is longer than {NAME_MAX}.

       [ENOENT]       The  path  argument  points to the name of a file which does not exist, or to an empty string and the environment defined is
		      POSIX or SYSTEM_FIVE.

       [ENOTDIR]      A component of path is not a directory.

       [ENOMEM]       Not enough memory was available to complete the file tree walk.

See Also
       stat(2), malloc(3)

																	    ftw(3)
All times are GMT -4. The time now is 07:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy