Sponsored Content
Top Forums Shell Programming and Scripting to parse a directory and its subdirectories and find owner name of files Post 302320250 by ghostdog74 on Wednesday 27th of May 2009 12:09:03 PM
Old 05-27-2009
if you have Python
Code:
#!/usr/bin/env python
import os,stat
for r,d,f in os.walk(os.path.join("/home","path","path2") ):
    for files in f:
        filepath=os.path.join(r,files)
        owner=os.stat(filepath)[stat.ST_UID]
        if owner!=0:
            print filepath

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find all files created by a specified user in a directory and its subdirectories

Is there a command or shell script which can be used for Finding all files created by a specified userid in a directory and its subdirectories. Say, I want to find all such files in directory /abc as well as in all the subdirectories such as /abc/xyz or /abc/xyz/pqr aqnd so on which was created... (5 Replies)
Discussion started by: abhilashnair
5 Replies

2. Shell Programming and Scripting

Shell:Find a word in files in a directory and subdirectories

I'm looking to write a ksh code with will be alble to find a word like 'toto' in all files going from my current directory. eg. /doc ----------->have: text.c which "toto" /doc/usr-------->have: build.pc, help.java which "toto" /doc/usr/cach -->have: test.sh which "toto" /doc/build... (4 Replies)
Discussion started by: yeclota
4 Replies

3. UNIX for Dummies Questions & Answers

Find Files in a Directory Excluding Subdirectories

Hi, I have a filename Location.txt in a directory /abc. Similar name file is present in its subdirectory /abc/xyz. I want to find the file which is present only in /abc and not in /abc/xyz. Please any1 of u can provide a quick suggestion. Its very urgent. Thanks, Amol (2 Replies)
Discussion started by: Amol_Dicholkar
2 Replies

4. Shell Programming and Scripting

Find directory name while traversing subdirectories

Hi, I have a parent directory in which I have sub directories of different depth /usr/usr1/user2/671 /usr/usr1/672 /usr/user2/user1/673 /usr/user2/user3/user4/674 And I need the names of all the directories that which starts only with 6 in a file. Thanks, (12 Replies)
Discussion started by: arun_maffy
12 Replies

5. UNIX for Dummies Questions & Answers

Group files by owner and show directory

Hello, i would like to find huge files and group them by owners. To find big files i use this command: ls -lR | sort -bnr +4 | head -n 75 which give me 75 biggest files, then i need to see in which subdirectory is every file. second thing i dont know is how to group those files by owner, could... (6 Replies)
Discussion started by: dealer1985
6 Replies

6. Shell Programming and Scripting

Find files only in current directory...not subdirectories

Hi, I have to find files only in the current directory...not in the sub directories. But when I use Find command ... it searches all the files in the current directory as well as in the subdirectories. I am using AIX-UNIX machine.Please help..I tried to use maxdepth..but it is not working in AIX. (2 Replies)
Discussion started by: vsachan
2 Replies

7. Shell Programming and Scripting

Find command to search files in a directory excluding subdirectories

Hi Forum, I am using the below command to find files older than x days in a directory excluding subdirectories. From the previous forums I got to know that prune command helps us not to descend in subdirectories. Though I am using it here, not getting the desired result. cd $dir... (8 Replies)
Discussion started by: jhilmil
8 Replies

8. Shell Programming and Scripting

Find/searching files in subdirectories excluding the fiels in Parent Directory

Hi All, requirement is to find and remove the files from sub directories but it should exclude the files from parent directory. At present i am using the below one but it finds and remove files from both parent and sub directories. find ${PATH} -type f \( -name securitas\* -o -name \*gz... (1 Reply)
Discussion started by: Naveenkk
1 Replies

9. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

10. AIX

How to set owner and permission for files/directory in directory in this case?

Hi. My example: I have a filesystem /log. Everyday, log files are copied to /log. I'd like to set owner and permission for files and directories in /log like that chown -R log_adm /log/* chmod -R 544 /log/*It's OK, but just at that time. When a new log file or new directory is created in /log,... (8 Replies)
Discussion started by: bobochacha29
8 Replies
zipios::FilePath(3)					     Library Functions Manual					       zipios::FilePath(3)

NAME
zipios::FilePath - FilePath represents a path to a file or directory name. SYNOPSIS
#include <filepath.h> Public Member Functions FilePath (const string &path='', bool check_exists=false) Constructor. FilePath & operator= (const string &rhs) operator string () const FilePath operator+ (const FilePath &name) const Concatenates FilePath objects. FilePath filename () const Returns filename of the FilePath object by pruning the path off. bool exists () const bool isRegular () const bool isDirectory () const bool isCharSpecial () const bool isBlockSpecial () const bool isSocket () const bool isFifo () const Protected Member Functions void pruneTrailingSeparator () Prunes the trailing separator of a specified path. void check () const This function sets _checked to true, stats the path, to see if it exists and to determine what type of file it is. Protected Attributes bool _checked bool _exists bool _is_reg bool _is_dir bool _is_char bool _is_block bool _is_socket bool _is_fifo string _path Static Protected Attributes static const char _separator = '/' Detailed Description FilePath represents a path to a file or directory name. FilePath has member functions to check if the file path is a valid file system entity, and to check what kind of file system entity it is, e.g. is it a file, a directory, a pipe etc. Definition at line 18 of file filepath.h. Constructor &; Destructor Documentation zipios::FilePath::FilePath (const string &path = '', boolcheck_exists = false) Constructor. Parameters: path A string representation of the path. check_exists If true is specified the constructor will check the existence and type of the path immidiately, instead of deferring that task until it is needed. Definition at line 18 of file filepath.cpp. Member Function Documentation void zipios::FilePath::check () const [protected] This function sets _checked to true, stats the path, to see if it exists and to determine what type of file it is. All the query functions check if _checked is true, and if it isn't they call check(). This means stat'ing is deferred until it becomes necessary. Definition at line 27 of file filepath.cpp. bool zipios::FilePath::exists () const [inline] Returns: true If the path is a valid file system entity. Definition at line 129 of file filepath.h. FilePath zipios::FilePath::filename () const [inline] Returns filename of the FilePath object by pruning the path off. Definition at line 119 of file filepath.h. bool zipios::FilePath::isBlockSpecial () const [inline] Returns: true if the path is block special (a block device file). Definition at line 157 of file filepath.h. bool zipios::FilePath::isCharSpecial () const [inline] Returns: true if the path is character special (a character device file). Definition at line 150 of file filepath.h. bool zipios::FilePath::isDirectory () const [inline] Returns: true if the path is a directory. Definition at line 143 of file filepath.h. bool zipios::FilePath::isFifo () const [inline] Returns: true if the path is a Fifo (a pipe). Definition at line 171 of file filepath.h. bool zipios::FilePath::isRegular () const [inline] Returns: true if the path is a regular file. Definition at line 136 of file filepath.h. bool zipios::FilePath::isSocket () const [inline] Returns: true if the path is a socket. Definition at line 164 of file filepath.h. FilePath zipios::FilePath::operator+ (const FilePath &name) const [inline] Concatenates FilePath objects. A file separator is inserted if appropriate. Definition at line 111 of file filepath.h. void zipios::FilePath::pruneTrailingSeparator () [inline, protected] Prunes the trailing separator of a specified path. Definition at line 100 of file filepath.h. Author Generated automatically by Doxygen for Zipios++ from the source code. Zipios++ Mon Oct 10 2011 zipios::FilePath(3)
All times are GMT -4. The time now is 11:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy