cancel
Showing results for 
Search instead for 
Did you mean: 
jeesshnasree
Starfighter Starfighter
Starfighter
  • 611 Views

How to find multiple users ID files total usage status list in directory

Jump to solution

Hello All,

 

Actually I need check all files & different user ID files contain one directory.

How to check total files with as per User ID with total usage in current directory command.

 

example :

File system path in Linux Operating Systems:

/tmp/example/

above mentioned path , example directory consuming 20 GB files , actually I need to find which user ID containing total memory details required.

please provide me command to check multiple users ID Total usage details in directory . 
once executed command then get output with as per users ID total utilization status required in current directory.

 

I hope explained my query.

could you please check and provide command.

I am waiting for your valuable information.

 

Thanks & Regards,

Jeesshnasree

Tags (1)
2 Solutions

Accepted Solutions
IanL
Cadet
Cadet
  • 541 Views

Hello jeesshnasree,

You can do this with find and awk. First use find to get a list of unique user names for the files contained in the directory. Then use find -user ${username} -ls and awk  to sum up the total size for all the files owned by that user.

 

Something like:

for user in `find . -type f -ls | awk '{ print $5}' | sort | uniq`
do
usage=`find . -type f -user $user -ls | awk '{total+=$7}; END{ print total}'`
echo "Usage for user $user: $usage bytes"
done

View solution in original post

jeesshnasree
Starfighter Starfighter
Starfighter
  • 511 Views

Hi @IanL ,

 

 

Thank you so much , its working . 

View solution in original post

2 Replies
IanL
Cadet
Cadet
  • 542 Views

Hello jeesshnasree,

You can do this with find and awk. First use find to get a list of unique user names for the files contained in the directory. Then use find -user ${username} -ls and awk  to sum up the total size for all the files owned by that user.

 

Something like:

for user in `find . -type f -ls | awk '{ print $5}' | sort | uniq`
do
usage=`find . -type f -user $user -ls | awk '{total+=$7}; END{ print total}'`
echo "Usage for user $user: $usage bytes"
done

jeesshnasree
Starfighter Starfighter
Starfighter
  • 512 Views

Hi @IanL ,

 

 

Thank you so much , its working . 

Join the discussion
You must log in to join this conversation.