Find Files in Directory by Permission?

 
Thread Tools Search this Thread
Operating Systems Linux Fedora Find Files in Directory by Permission?
# 8  
Old 09-24-2009
can you post the script?

the find ..-exec flag is for operating on every find result. Think of batch renaming, archiving, or deleting.
# 9  
Old 09-24-2009
The VMWare won't allow me to have a shared clipboard. I could, however, take a pic.

http://img85.imageshack.us/img85/5025/codep.jpg
# 10  
Old 09-24-2009
I tried to post an image. Says a moderator needs to accept it. Ugh.

But this is making no sense. I could be done with this now if it weren't for Fedora deciding it's going to defy logic. The big line starting with Find. Right? That equals 6 for my test directory. Which is correct. That big line is what my "Count" value should be. So I decide I'll write that count to "COUNT". Then IMMEDIATELY, for the sake of testing, echo it to verify it'll spit out the right value. But nothing. It's actually NOT echoing when I'm clearly telling it to. I'm very confused.

Example: COUNT=find $directory -type f -perm 666 -print | wc -l
echo $count


and nothing displays.

Then I was like "COUNT="loltest"
echo $count

and nothing. Why aren't my values displaying now?


http://img85.imageshack.us/img85/5025/codep.jpg

Last edited by Feuyaer; 09-24-2009 at 06:29 PM..
# 11  
Old 09-24-2009
echo $count will display the value of 'count' but not of 'COUNT'.

what does 'echo $COUNT' display, or are you just typing in haste?
# 12  
Old 09-24-2009
Nope.

I can say

COUNT="lol"
echo $COUNT

and nothing is happening....?


I really don't know what happened. I just made a NEW code and simply told it to echo something. And nothing comes up. It....stopped echoing entirely? Wow.

is this right? I'm trying an If statement to check if the number isn't 0.

if [ find $directory -type f -print -perm 666 ] -gt 0

...etc etc. But it's not working. No error messages, but it's not working.
I tried putting the -gt 0 in the brackets, but same thing.

Last edited by Feuyaer; 09-24-2009 at 06:52 PM..
# 13  
Old 09-24-2009
Ok, I checked your image.

You are doing this:
Code:
find $directory -type f -perm 666 -print | wc -l > results.txt

which is outputting the result of 'wc' to 'results.txt' Thus results.txt contains something like
Code:
 6 results.txt

Then you set
Code:
count=wc -l results.txt

which is always going to be 1.

What you want to do instead is:
Code:
find $directory -type f -perm 666 -print > results.txt
count=wc -l results.txt|cut -f1 -d' '

that will output the results of the find to the file, and then you wordcount on it.
you can insert a 'cat results.txt' to check its contents too.

not sure about your new echo problem.
# 14  
Old 09-24-2009
Yeah the echo thing is still a problem. But I re-entered that code you typed and everything works the same still. But still I can't echo anything else AND no matter what sort of If-Else I put it to ensure it's not zero, it does nothing. I even tested the If-Else once by changing the parameter to SDFSEFDG WRGDF. Just random text. And nothing happened. No error. It's ignoring my text. Ugh. I guess I'll have to hand in this assignment without an If-Else if this programs going to break down on me like this.

Thanks for your help thus far though. I have one last part of the assignment that I might need to ask some questions about, if you're still willing to answer a few questions here.

---------- Post updated at 08:42 PM ---------- Previous update was at 07:14 PM ----------

Sorry for the double post, I wasn't sure if just editing the last post would make my helper here re-check the topic.

Now I need to do something similar then different. Have the user input a directory again. Verify it. But then:
-Loop through allll (?) the files and find how many total sub-directories branch from the specified directory.
-Name the newest, and oldest, of these sub-directories. I really don't know where to begin. I might have a grasp on looping but I'm not sure of what I'd use to go through directories....whether there's a simple command, or if I need to use a whole lot of ls shenanigans to go through a hundred things....?

Heh. Any tips, pointers, or good commands to use here?



-Edit: I'm impressed with myself lol. In a single day of Unix I've figured out most of this assignment I'm one currently. The one thing I can't quite get is bugging me though. If the selected directory has only one subdirectory, it is to be named. In a message. There's messages like "no subdirectories were found", but I need a way to find the name of the one and only subdirectory, if a folder has just one. cd......sooomething. I'm not sure of the name, and I need to find out.. Smilie

Last edited by Feuyaer; 09-24-2009 at 10:33 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
Login or Register to Ask a Question