LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Have a few questions about displaying files (https://www.linuxquestions.org/questions/linux-newbie-8/have-a-few-questions-about-displaying-files-678842/)

incomingid 10-24-2008 11:56 AM

Have a few questions about displaying files
 
MY questions:

1) Display a list of all the files under the /etc directory and its sub-directories that have been created or modified within the last 60 minutes.

2) Display a list of all the files under the /var directory and all its sub-directories that have been created or modified today (since mid-night).

3) Display a list of all the files under the /home directory and all its sub-directories that have been created or modified within the last 8 days.

4) Display a list of all the files under the /tmp directory and all its sub-directories that were more than 15 days old

I count find answer for those questions.

TB0ne 10-24-2008 12:37 PM

Quote:

Originally Posted by incomingid (Post 3320921)
MY questions:

1) Display a list of all the files under the /etc directory and its sub-directories that have been created or modified within the last 60 minutes.

2) Display a list of all the files under the /var directory and all its sub-directories that have been created or modified today (since mid-night).

3) Display a list of all the files under the /home directory and all its sub-directories that have been created or modified within the last 8 days.

4) Display a list of all the files under the /tmp directory and all its sub-directories that were more than 15 days old

I count find answer for those questions.

Google for "atime", "mtime", and "ctime". This page can help you

http://dsl.org/cookbook/cookbook_10.html

pixellany 10-24-2008 12:41 PM

Homework??

I would start with "man find" (enter this in a terminal)

onebuck 10-24-2008 02:42 PM

Hi,

Definitely homework and someone too lazy too use the tools available.

I would suggest that you look at 'man ls', 'man ctime' and 'man find'.

Plus look at the next links;

incomingid 10-25-2008 02:00 AM

I am not lazy. I finished more then half of the assignment myself. But some of the questions I cant find. The assignment contains 38 questions and all of them are research questions ( not thought in class). I just need some help with some of the questions. Its not about me being lazy. I am not trying to use anyone in a rude manner. I am sorry if I have u the wrong impression.

jschiwal 10-25-2008 02:33 AM

Well, how about some extra credit! Download the source packages for "findutils" and "coreutils". Generate the "Finding Files" and "Core Utils" pdf or dvi manuals and print them out. The coreutils manual has instructions on about 100 commands. Most of them are basic commands like cp and mv. Having it in a book format can help you learn these commands easier and remember them. You can resort to the printout while trying many of them out. Some of the commands like "comm" and "dd" are real gems. Some commands like "tsort" you will probably never use, but other like "tee".

The find command finds files based on criteria that you indicate. It is like a swiss-army-knife. You can find all of the suid programs on your system and see which ones you could uninstall. You can select by size, date, timestamp or name pattern, combining them, and even do something with the results. You can also print out the results in different ways, such as the name, inode, size, ownership.

Also look at the xargs command. Find and xargs are often used together to be able to handle very large result sets. If you have 30,000 files in a directory, wildcards may choke bash with too many arguments. find piped to xargs is a solution you will run into in the future.

Good Luck.

onebuck 10-25-2008 10:30 AM

Hi,

Quote:

Originally Posted by incomingid (Post 3321464)
I am not lazy. I finished more then half of the assignment myself. But some of the questions I cant find. The assignment contains 38 questions and all of them are research questions ( not thought in class). I just need some help with some of the questions. Its not about me being lazy. I am not trying to use anyone in a rude manner. I am sorry if I have u the wrong impression.

Then you should have formed your post a little better (How to Ask Questions the Smart Way). If you had formed it with the taste of the last then you may have gotten more assistance initially.

Good that you have finished at least part of the assignment. If you are having problems with specifics then these should be addressed to your prof/instructor/teacher first. That way he/she can see where the attention is actually necessary. I come from academia and knowing a students weakness or strengths was important so that we could form a means that would really work. Any teacher would not criticize a student that is duly trying to accomplish a task(s). Most would welcome the opportunity to teach that person.

The challenge that we presented was somewhat of a test too. You should see the number of homework type questions here on LQ. Most people will help someone who is attempting to help themselves.

I'm sure that your assignment has support documentation or instructions as to where to reference or where the instructor may example your assignment support. The questions you presented in the original post are general so the tasks do build on each other in a sense, 'jschiwal' has given you a good lead so I suggest that you use it.

I would add that 'Advanced Bash-Scripting Guide' is a good reference for you too look at and have as support documentation. Along with 'Linux Newbie Admin Guide', 'Linux Command Guide' and 'Learning the Shell' you should be able to understand a little better. Just remember the hardest thing is going to be is too breaking down your assignment to the simplest terms and to tackle those terms outwardly.

john test 10-25-2008 02:36 PM

Seems like "watch" might work to track updated files in /etc directory.

incomingid 10-31-2008 11:15 AM

Ty for your help. I found the answer :D

find /etc -mmin +60
find /var -daystart
find /home -mtime -8
find /tmp -mtime +15


Now I just have to hope its the right answer :>a

Thanks again.

john test 11-01-2008 08:59 AM

Isn't there an error in the first solution?
shouldn't that be -60? (Per the original Post)

incomingid 11-03-2008 11:03 AM

Quote:

Originally Posted by john test (Post 3328197)
Isn't there an error in the first solution?
shouldn't that be -60? (Per the original Post)


When i use +60 it gives me a long long log.
When I use -60 it gives me a shorter long. So I'm guessing -60 is the right answer. Thank you for pointing that out.

john test 11-03-2008 11:24 AM

You are very welcome.


All times are GMT -5. The time now is 07:43 PM.