- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Perl/ksh script to find files used by users...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2006 06:42 AM
тАО07-20-2006 06:42 AM
We have directories like /home11 that store users directories. I need a perl/ksh script that searches the directories, lists the files from biggest to smallest and detirmines whther or not any of these diirectories or files is an orhan.
-TIA
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2006 06:47 AM
тАО07-20-2006 06:47 AM
Re: Perl/ksh script to find files used by users...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2006 06:48 AM
тАО07-20-2006 06:48 AM
Re: Perl/ksh script to find files used by users...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2006 06:49 AM
тАО07-20-2006 06:49 AM
Re: Perl/ksh script to find files used by users...
find . -type f -nouser -print
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2006 06:54 AM
тАО07-20-2006 06:54 AM
Re: Perl/ksh script to find files used by users...
# perl -MFile::Find -le'find(sub{-f and push@{$f{-s$_}},$File::Find::name},@ARGV);for$s(sort{$b<=>$a}keys%f){printf"%9d %s\n",$s,$_ for sort@{$f{$s}}}' /home11
Enjoy, Have FUN! H.Merijn
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2006 06:54 AM
тАО07-20-2006 06:54 AM
Re: Perl/ksh script to find files used by users...
# find /home -xdev -nouser
# find /home -xdev -nogroup
...will find your unowned (no password or no group)
For listing the contents from largest to smallest:
# du -xk /home|sort -k1nr
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2006 07:00 AM
тАО07-20-2006 07:00 AM
Re: Perl/ksh script to find files used by users...
# perl -MFile::Find -le'find(sub{-f and push@{$f{-s$_}},[$File::Find::name,(stat$_)[4]]},@ARGV);for$s(sort{$b<=>$a}keys%f){printf"%4s %9d %s\n",($_->[1]eq getpwuid$_->[1]?"ORPH":""),$s,$_->[0] for sort@{$f{$s}}}' /home11
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2006 07:05 AM
тАО07-20-2006 07:05 AM
Re: Perl/ksh script to find files used by users...
for file in $(find . -type f);
do
filesize=$(ls -l $file | awk '{print $5}')
fileowner=$(ls -l $file | awk '{print $3}')
orphan=""
if [[ $(grep -c "^$fileowner:" /etc/passwd) -eq 0 ]];
then orphan="ORPHANED FILE!"
fi
echo "$filesize $file $orphan"
done | sort -nr +0
HTH,
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2006 07:07 AM
тАО07-20-2006 07:07 AM
Re: Perl/ksh script to find files used by users...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2006 07:59 AM
тАО07-20-2006 07:59 AM
Re: Perl/ksh script to find files used by users...
Is there a way to combine the two perl statements?
Sorry but, I am still trying to learn perl.
THanks,