Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Search this Thread
  #8  
Old 09-10-2009
Registered User
 

Join Date: Aug 2007
Posts: 33
Thanks: 2
Thanked 0 Times in 0 Posts
Thanks to all for their answers for this one.
It seems this could be very interesting thread.
Unfortunately, all ways metioned here to get the n largest files on the server , are not still how i imagined that this could be done.
Firstly , i am always getting the complete list of files that are searched on the screen, along with the messages like

Code:
find: //proc/3354/task/3354/fd: Permission denied

I am executing all those commands you suggested as oracle, not root.
And secondly , i still didn't recived result similiar to the following , something like
this, ONLY the first 5 biggest files(at least from the ones that i have permission to read) let's say in descending order; this should look like this i suppose :


Code:
/path/to/the/file/filename.ext 1000
/path/to/the/file/filename.ext   900
/path/to/the/file/filename.ext   800
/path/to/the/file/filename.ext   700
/path/to/the/file/filename.ext   600

Where those number would be bytes/megabytes of that file....

Is there something that could give this kind of result ? Without printing on the screen of the whole search/find/permissions issue process ?
...or even this output without those file size numbers...

sorry if I missunderstood/misstyped commads you provided , maybe they do exactly this ..
Sponsored Links
  #9  
Old 09-10-2009
Registered User
 

Join Date: Mar 2008
Posts: 2,359
Thanks: 8
Thanked 67 Times in 66 Posts
It is not possible to find the largest files on the system unless you have root access. User "oracle" is no more special than any other normal user.
  #10  
Old 09-10-2009
thegeek thegeek is offline Forum Advisor  
Registered User
 

Join Date: Apr 2009
Location: /usr/bin/vim
Posts: 927
Thanks: 6
Thanked 18 Times in 16 Posts
1. Firstly, you should have permission to all the files if you'd want to find out biggest file in the whole file system.

So better try to run the find command with the super user privilege, else you would be getting those kind of errors.

2. Secondly, if you don't want to see the errors then you can redirect it to /dev/null as,

Code:
find / -type f -exec ls -s {} \; 2>>/dev/null | sort -n -r | head -5

Also this find command would show the file names and sizes in descending order as you expected. ( but size first, and then the file name next. )

Hope this helped !
  #11  
Old 09-11-2009
Registered User
 

Join Date: Aug 2007
Posts: 33
Thanks: 2
Thanked 0 Times in 0 Posts
thanks thegeek , you are really a geek. This is doing exactly what i wanted.
Could you please explain and point in the code you wrote how the redirect of the erorr is done,what is the purpose od dev/null and how is descending sort done ?
  #12  
Old 09-11-2009
thegeek thegeek is offline Forum Advisor  
Registered User
 

Join Date: Apr 2009
Location: /usr/bin/vim
Posts: 927
Thanks: 6
Thanked 18 Times in 16 Posts
Yes, definitely i can explain.


Code:
find / -type f -exec ls -s {} \; 2>>/dev/null | sort -n -r | head -5

  • find / -type f
    • find only files from /
  • -exec ls -s {} \;
    • execute ls -s command, on each file
  • 2>>/dev/null
    • 2 means stderror
    • /dev/null -- ( from wiki: In Unix-like operating systems, /dev/null or the null device is a special file that discards all data written to it )
  • | sort -n -r
    • pipe the output,
    • sort does reverse numeric sorting.
  • | head -5
    • display only first 5 lines.

It is actually from my write up here, i hope you will definitely be interested in reading this:
Mommy, I found it! — 15 Practical Linux Find Command Examples
  #13  
Old 09-11-2009
Registered User
 

Join Date: Aug 2007
Posts: 33
Thanks: 2
Thanked 0 Times in 0 Posts
well, thanks a bunch !
And that link you provided with your write up is very interesting !
thanks!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
To find largest and shortest word in eld Markwaugh Shell Programming and Scripting 2 04-16-2009 11:39 PM
Find and display largest file on system raidkridley Shell Programming and Scripting 4 10-20-2008 12:54 AM
find the largest file in whole system megh HP-UX 7 08-05-2008 12:17 PM
find largest file mohan705 Shell Programming and Scripting 15 07-04-2007 02:34 AM
find the 5o largest files in a directory igidttam Filesystems, Disks and Memory 8 05-16-2007 01:20 PM



All times are GMT -4. The time now is 11:23 PM.