Results 1 to 1 of 1
I've been working on this for a while and can't seem to get it right. I'm working on a script that will eventually be run as a cron job. From ...
- 03-15-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 1
File System Audit
I've been working on this for a while and can't seem to get it right. I'm working on a script that will eventually be run as a cron job. From Linux I'm mounting a remote Windows share as /media/windows_share The share I'm mounting is for user's personal drive. Some people seem to have a bunch of audio files. I can search for them using
I've even pipped that in toCode:find /media/windows_share -iname "*.mp3" -o -iname "*.wma" -o -iname "*.m4a"
The output results in tons and tons of full paths to files. The folder structure is /media/windows_share/department_name/user_name for example:Code:du -h
/media/windows_share/finance/john doe
When I run the script, I'd like to it to NOT show me the full path of all the music files but instead show /department/user_name and how much disk space the audio files they're storing are using. *please note that the user names are full first name and full last name separate by a space. So far I've managed to get the a script that will give me just the department name and user name, but I can't get it to give me the disk space usage. I also get a dc: stack empty message
Here's what I've got so far
Any help would be appreciatedCode:#!/bin/bash mtp="/media/windows_share" >found.files ls $mtp|while read dept;do ls $mtp/$dept|while read user;do echo $dept/$user; find "$mtp/$dept/$user" -maxdepth 20 -iname "*.wma" -o -iname "*.mp3" -o -iname "*.m4a"|while read files;do count=`du -h "$files"|awk '{print $1}'|grep "M"|awk -F "M" '{print $1}'`; echo -n "$count+">>found.files; done echo -n "p">>found.files; dc -f found.files; echo; >found.files; done done


Reply With Quote