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.
Use ls -l and grep to find all the files in /etc that were last modified in 2010. Sort this list in descending order of size and send the output to s7.
#I have spent hours looking for the answer to this.
If you look at "man ls", you will see that the -t option lets you sort by modification time, and -S is for sorting by file size. You could pipe the results from ls into grep, searching for the pattern 2010.
If you look at "man ls", you will see that the -t option lets you sort by modification time, and -S is for sorting by file size. You could pipe the results from ls into grep, searching for the pattern 2010.
What is s7?
s7 is the name of file to direct the output to. i'll try it now and get bacK asap
"didn't work" isn't enough information. you have to say what happened and in what way it didn't meet your expectations. Also you need to read the ls man page more carefully. -s is not the same as -S.
Most likely you have to specify which is the field to use for sorting (size is usually the 5th field in the output of ls). Take a look at option -k of the sort command. Anyway, you don't need to pipe the results to sort if you already use the -S option of ls, unless you use ls -lR to descend recursively into subdirectories (beware the question is "to find all the files in /etc").
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.