Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
Before I start this thread, I should probably state that I'm still relatively new to Linux. I'm using Fedora Core 6 in a class at school and in an assignment I have to do the following.
Display a list of all the files under the /tmp directory and its sub-directories that have been created or changed within the last 30 minutes.
Needless to say, I'm a bit confused as to where to begin with this. I've done some research and I think but I'm not sure that it will involve the ls -t function, however I'm not sure how to use this code and I can't seem to find any reference on it.
If you guys could help me in any way it would be greatly appreciated!
Take a look at the rules on homework
We are allowed to help you, and your initial post will motivate people to help..
In addition to ls, take a look at the find command (do "man find") it has options for filtering for various time parameters---eg access time, modification time, etc.
-t does sort by modification time but "ls" by default gives you all files. Also without the -l option you don't actually see the times.
The documentation for commands in UNIX and Linux is "man". Just type "man ls" and you'll see a lot of information about the ls command. Linux also has "info" pages that sometimes give you more information about commands. At a minimum info will usually show you what is in man.
You might also think about using the "find" command instead of ls. A hint - look discussion about the -newer option.
I could give you the answer but since it's for homework it will probably help you to work it out from the man page. Learning how to use those will come in very handy if you decide to pursue work in Linux or UNIX.
Try the man ls or info ls to see the online documentation for the lscommand.
Look in the same places for the documentation of the sort command and the grep command.
Then do a info bash and look up the description of the "pipe" directive which takes the output of one command and makes it the input of the second command.
So you end up with something like this:
$ ls -l /tmp | grep -r ... | sort ... where the grep selects the files you want listed from the ls output, and the sort arranges them in the desired order.
But that's all assuming that your class is one for Linux usage.
If it is, instead, a programming class, then you need to start a new thread in the "programming" sub-forum.
I appreciate the help. I should also state that Im very familiar with the man pages and piping, however I was unaware as to what command I should go about using to achieve the desired result.
I also never expected you guys to do the homework for me, I just wanted a point in the right direction :P
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.