Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Its been a while and my skills are a bit rusty to say the least. I need a script tha will display the file name of the smallest file and the largest file in a specified directory. Also the average filesize of the directory??
I know the method of figuring out the min and max of int/double values. I just dont know the commands to retrieve the information i need.
I also need to incorporate if the user chooses the -R option the ability to scann the directory tree recursively??
tha will display the file name of the smallest file and the largest file in a specified directory. Also the average filesize of the directory?? I know the method of figuring out the min and max of int/double values. I just dont know the commands to retrieve the information i need. I also need to incorporate if the user chooses the -R option the ability to scann the directory tree recursively??
If this is part of a homework assignment then please read the LQ Rules about that. If this is not a homework question and your skills are not nonexistant, then you should post what you got already so we can build on that. Also note that if you have a question it helps asking for it properly, especially if your skills are nonexistant and would like other people to do your work for you. You don't have to say "please" but at least using the right phrasing and a question mark should help.
Relax my friend...I fear that you are paranoid and slightly uptight. You could have used that energy to actually respond to the question....
But to ease your stress...Here is what I have/know so far.
I know that ls -l | awk '{print $5}' will print the file size for all files and that i can even to a arithmetic expression to figure out the sum off all sizes...which maybe useful if i can then get the total number of files and divide by this to evaluate the average.
I know that du and wc -c will also give me file sizes...
My only issue is how I could get each file size one at a time (from first to last) so I can then do a comparison to see if it is the current min or max size. Can do this in a for loop until there are no more files to check.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.