LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 02-16-2007, 11:58 AM   #1
D-KNUCKLES
LQ Newbie
 
Registered: Feb 2007
Posts: 3

Rep: Reputation: 0
Sorting Question


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!

Thanks so much
 
Old 02-16-2007, 12:33 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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.
 
Old 02-16-2007, 12:33 PM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
-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.
 
Old 02-16-2007, 12:37 PM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Try the man ls or info ls to see the online documentation for the ls command.

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.
 
Old 02-16-2007, 01:40 PM   #5
D-KNUCKLES
LQ Newbie
 
Registered: Feb 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks a lot for the feedback guys

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
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL question on sorting (should be simple) BrianK Programming 3 08-09-2006 09:20 PM
Sorting data. unreal128 Linux - Software 1 09-20-2005 06:31 PM
sorting and stuff arnulfo Programming 13 01-01-2005 04:37 PM
Sorting Beppe83 Linux - Software 7 06-21-2004 09:10 AM
Sorting question AMMullan Linux - General 12 01-19-2004 03:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration