Visit Our UNIX and Linux User Community


Group files by owner and show directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Group files by owner and show directory
# 1  
Old 05-01-2011
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:
Code:
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 someone help me?, have no idea how to do it.

Was trying to play with 'find' command etc but it dont work like i want
The structure i would like to get is following
Code:
name_user1
drwxr-xr-x   4 user1     root           7 Feb 22  2007 file1
drwxr-xr-x   4 user1     root          15 Feb 23  2007 file2
drwxr-xr-x   4 user1     root          20 Apr 13  2007 file3
drwxr-xr-x   5 user1     root          32 Jul 19  2007 file4
drwxr-xr-x   4 user1     root          46 Jul 30  2007 file5
drwxr-xr-x   5 user1     root          56 Sep 20  2007 file6
dr-xr-xr-x   5 user1     sys           67 Mar 24  2008 file7
name_user2                                             
drwxr-xr-x   8 user2     other          9 Jun 16  2008 file1
drwxr-xr-x   6 user2     root          19 Oct 10 12:50 file2
drwxr-xr-x   5 user2     root          26 Oct 14 18:17 file3
drwxr-xr-x   2 user2     root          35 Nov 13 13:37 file4
drwxr-xr-x  76 user2     root          46 Nov 21 09:01 file5
drwxr-xr-x   6 user2     root          58 Nov 27 07:34 file6
drwxr-xr-x  11 user2     root          62 Jan 12 15:39 file7
drwxr-xr-x   5 user2     root          95 Jan 12 15:57 file8
name_user3                                             
drwxr-xr-x   3 user3     root           3 Jan 13 09:01 file1
drwxr-xr-x   3 user3     other          8 Jan 13 11:17 file2
drwxrwxr-x   5 user3     other         61 Jan 13 13:01 file3

i know that i can get user_name from /etc/passwd but how to make it so nice ordered?
Thanks for you help
# 2  
Old 05-02-2011
Code:
find . -type f -size +100k -ls |sort -k7rn|head -75 |sort -k5

# 3  
Old 05-23-2011
Hello, when i use this command i get following error
Code:
find: Error in processing the argument 100k



that one dosent give any error but its not what i am looking for
Code:
find . -type f -size +100 | sort -k7rn | head -75 | sort -k5

# 4  
Old 05-31-2011
i see that noone knows it
some ideas?
thanks
# 5  
Old 05-31-2011
Quote:
Originally Posted by rdcwayx
Code:
find . -type f -size +100k -ls |sort -k7rn|head -75 |sort -k5

That appears to work ok for me, what problems are you having with it?

Edit: Looking at your problem with the 100k parameter it looks like you are not using the GNU version of find, what platform are you working on?

H.

Last edited by Haqa; 05-31-2011 at 10:21 AM..
# 6  
Old 05-31-2011
HP-UX - its what you mean?
# 7  
Old 05-31-2011
Quote:
Originally Posted by dealer1985
HP-UX - its what you mean?
Ahh, yes, the standard find command on HP-UX only accepts blocks (512 Bytes) or bytes as parameters for the size option. The default is blocks so, your 100k would be "-size +200" or "-size +102400c". Also, the "-ls" option doesn't appear to be supported so use "-exec ls {} \;" instead.

Other than that the sort command and head command should accept those parameters so the command should work.

So the command becomes
Code:
find . -type f -size +102400c -exec ls {} \; |sort -k7rn|head -75 |sort -k5

H.
This User Gave Thanks to Haqa For This Post:
 

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List files whose owner or group is numeric

I want to add a condition is my find command to include files/sub-directory whose owner or group is all numeric number. My current find command is find . \( -user root -o -user soham\) -type f -exec ls -l {} \; 2>&1 ---------- Post updated at 10:20 AM ---------- Previous update was at... (5 Replies)
Discussion started by: Soham
5 Replies

2. Shell Programming and Scripting

Search for files owned by particular owner and group

I am searchingfor files owned by particular owner and group in a particular directory including its sub-directories. I use find <dir> -user <user> -group <group> -exec ls -l {} \; It does not work completely. In the sense is a subdirectory is owned by 'user' and group 'group' then all... (9 Replies)
Discussion started by: Soham
9 Replies

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

4. AIX

Files without owner and group

Dears it is normal that the below binaries stay without any owner and group I have checked it in many servers and the like the below /usr/lpp/bos.net/inst_root/etc/ipsec# ls -lrt total 248 -r-xr-xr-x 1 987 987 13589 Jun 29 2005 default_group -r-xr-xr-x ... (5 Replies)
Discussion started by: thecobra151
5 Replies

5. Emergency UNIX and Linux Support

To identify the group owner

If I have to identify the group owner of an AIX group, what is the command to be used. Example: there is an mqadm group, how do I find the owner of this group? Please help. (6 Replies)
Discussion started by: ggayathri
6 Replies

6. UNIX for Dummies Questions & Answers

Finding the Group Owner Name

Hi all, How can i find the group owner name...??? Thanks (4 Replies)
Discussion started by: mansahr143
4 Replies

7. UNIX for Advanced & Expert Users

How UNIX admin set up this? how files of 744 of other owner can be removed by another owner?

Hi all, We have some files are under 744 permissions and the the owner is say owner1 and group1. Now we have another user owner2 of group2, owner2 can remove files of the owner1 and the permission of those files are 744, unix admin told us he did some config at his side so we can do that. ... (14 Replies)
Discussion started by: TheGunMan
14 Replies

8. Shell Programming and Scripting

to parse a directory and its subdirectories and find owner name of files

hi all, i need to capture all the files in a directory and its subdirectories that have owner name different than the root owner. for one file it is " stat -c %U filename " but i need to search for each and every file and record it. thanks in advance (14 Replies)
Discussion started by: vyasa
14 Replies

9. Shell Programming and Scripting

permission, owner and group

hello I search a script (ksh for Aix 5.3) to save all permissions, groups and owner for all files. Because we work much to change it, and a mystake ......! So i want execute this script to save/ execute permissions for all files. If you have this script, thank you for your help ;) best... (2 Replies)
Discussion started by: pascalbout
2 Replies

10. UNIX for Dummies Questions & Answers

owner and group in Linux

I am bit unclear of how Linux was set in the real world, please advise me how it's supposed to be. When I log in as root and do a ls -l, I find: /boot, /, /var, /usr, /tmp, /home, /u01, /u02, /u03 and of of this partition is owned by root and the group also belong to root. Is that the way it's... (1 Reply)
Discussion started by: lapnguyen
1 Replies

Featured Tech Videos