Sponsored Content
Operating Systems Linux Fedora Find Files in Directory by Permission? Post 302356111 by Feuyaer on Thursday 24th of September 2009 01:37:50 PM
Old 09-24-2009
Find Files in Directory by Permission?

Hello. I need to write a script that lets the user pick a directory. Then, all files are looped through, and the ones with read-write (for current user I think) are listed. Ending with a count of those files, but that parts easy. What I'm confused about is the middle.

So far I have

#!/bin/bash

clear

return=0
echo "please enter a directory name."
read directory

if [ -d "$directory" ]
then
echo "The $directory directory exists, looking..."
#LOOP SECTION HERE

else
echo "$directory does not exist"
return=1
fi
exit $return

Now I havent finished the WHOLE thing, but where I have the #comment is where I'm stuck and presumably where I'd begin the loop. How do I search the user input $directory for read-write files?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to find the count of files in a directory

Hi Gurus WHat would be the command to check whether there is a file in particular path or not.. for ex: my file name is ExRate_20071501.csv I can have many files with same pattern but diffrentiated by date.. i have a process where i have to check if files exist in tht folder i have to... (5 Replies)
Discussion started by: sish78
5 Replies

2. Shell Programming and Scripting

How to find a specific files in a many directory

Dear All, Appreciate some help here. I have a log of report. It located in several directory as below: Directory: mysscpr1 mysscpr2 mysscpr3 my_scnpr4 In the directory it contain hundred of files. i need to find a specific files that contain 'invc2345' in the directory. How... (7 Replies)
Discussion started by: selamba_warrior
7 Replies

3. Shell Programming and Scripting

Find files in directory

Hi all I want to find a particular file type lets say .abc under /home/oracle/, the file name is start with 'D' and followed by ddmmyyyy date format, the file name should look like this D19092008.abc To my question, how can i perform the searching from the date 19/09/2008 to 29/09/2008. The... (3 Replies)
Discussion started by: coldstarhk
3 Replies

4. UNIX for Dummies Questions & Answers

Need help to find the files under a directory

Hi, I wanted to delete all the files under a directory "/apps/tmp/" which are two weeks older. But i should not delete the sub-directories and the contents of sub-directories. I also have searched in forum and found the following command, find . \( ! -name . -prune \) -mtime +13 -print ... (8 Replies)
Discussion started by: Sheethal
8 Replies

5. UNIX for Dummies Questions & Answers

Find files and display only directory list containing those files

I have a directory (and many sub dirs beneath) on AIX system, containing thousands of file. I'm looking to get a list of all directory containing "*.pdf" file. I know basic syntax of find command, but it gives me list of all pdf files, which numbers in thousands. All I need to know is, which... (4 Replies)
Discussion started by: r7p
4 Replies

6. UNIX for Dummies Questions & Answers

How to Find Files other than specified directory ?

Hi All, I am creating one script to Archive the older log files to Archive folder and deleting older files. For example below path contains different sub folders. So searching for log files older than 2 days then zip and moving to Archive directory in the same directory. Source files :-... (4 Replies)
Discussion started by: vadlamudy
4 Replies

7. UNIX for Advanced & Expert Users

Find all files in the current directory excluding hidden files and directories

Find all files in the current directory only excluding hidden directories and files. For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided. `find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
Discussion started by: ksailesh1
7 Replies

8. UNIX for Dummies Questions & Answers

find Files in sub-directory

Hi Just want to ask, Is it possible to find a file from a directory up to its sub-directories? Thanks, cmarzan (10 Replies)
Discussion started by: cmarzan
10 Replies

9. 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

10. Shell Programming and Scripting

Find list of files missing read & execute permission

Hi, I'm writing a post-upgrade script and I want to find which files don't have read and execute to everyone. I can run a find . ! -perm, but then I have to use a list of the possible permissions (777,775, 755 etc). Is there a more elegant solution? Thanks (2 Replies)
Discussion started by: Catullus
2 Replies
File::Find::Object::Rule::Extending(3pm)		User Contributed Perl Documentation		  File::Find::Object::Rule::Extending(3pm)

NAME
File::Find::Object::Rule::Extending - the mini-guide to extending File::Find::Object::Rule SYNOPSIS
package File::Find::Object::Rule::Random; use strict; use warnings; # take useful things from File::Find::Object::Rule use base 'File::Find::Object::Rule'; # and force our crack into the main namespace sub File::Find::Object::Rule::random () { my $self = shift()->_force_object; $self->exec( sub { rand > 0.5 } ); } 1; DESCRIPTION
File::Find::Object::Rule inherits File::Find::Rule's extensibility. It is now possibile to extend it, using the following conventions. Declare your package package File::Find::Object::Rule::Random; use strict; use warnings; Inherit methods from File::Find::Object::Rule # take useful things from File::Find::Object::Rule use base 'File::Find::Object::Rule'; Force your madness into the main package # and force our crack into the main namespace sub File::Find::Object::Rule::random () { my $self = shift()->_force_object; $self->exec( sub { rand > 0.5 } ); } Yes, we're being very cavalier here and defining things into the main File::Find::Object::Rule namespace. This is due to lack of imaginiation on my part - I simply can't find a way for the functional and oo interface to work without doing this or some kind of inheritance, and inheritance stops you using two File::Find::Object::Rule::Foo modules together. For this reason try and pick distinct names for your extensions. If this becomes a problem then I may institute a semi-official registry of taken names. Taking no arguments. Note the null prototype on random. This is a cheat for the procedural interface to know that your sub takes no arguments, and so allows this to happen: find( random => in => '.' ); If you hadn't declared "random" with a null prototype it would have consumed "in" as a parameter to it, then got all confused as it doesn't know about a '.' rule. NOTES ABOUT THE CALLBACK
The callback can access the File::Find::Object::Result using "$self->finder->item_obj()". AUTHOR
Richard Clamp <richardc@unixbeard.net> COPYRIGHT
Copyright (C) 2002 Richard Clamp. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
File::Find::Object::Rule File::Find::::Rule::MMagic was the first extension module for File::Find::Rule, so maybe check that out. perl v5.14.2 2012-05-05 File::Find::Object::Rule::Extending(3pm)
All times are GMT -4. The time now is 08:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy