list of files modified 10 hours ago using grep

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions list of files modified 10 hours ago using grep
# 1  
Old 07-05-2011
list of files modified 10 hours ago using grep

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

Here is the question:

Make a list of files in your home directory that were changed less that 10 hours ago, using grep, but leave out directories.

I just started studying LINUX for about 2 weeks.


2. Relevant commands, code, scripts, algorithms:

The code should have grep.

3. The attempts at a solution (include all code and scripts):

ls -l /root | grep -v '^d'

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Linux Programming - CS 310 - Dr. James Hendrikson

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 07-05-2011
1) Make a list of files in your home directory

so, use /home/username

2) ls -l /home/username | grep -v "^d"

The above command will give only the files which is present under your home directory

3) If you want to use only grep command, then first you have to find out the current hour using
Code:
date +%H

4) Then read the lines one by one and extract the hour and do the comparsion. (But it is very tricky part), as you need to calculate and compare the date for some time (example : if the current time is 03:00, then you need to list the files which is having the time as 17:00 or less of last day )

5) Best approach is use find command instead of grep command.


find
# 3  
Old 07-05-2011
thank you so much!
# 4  
Old 07-05-2011
For your home directory, instead of using /home/username, you should use the $HOME environment variable, which is almost* guaranteed to be set. Some (but not all!) shells support tilde expansion as in ~/ expands to ${HOME}/.

* There are some odd circumstances where this is not true, but you will likely not encounter them during your coursework.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to find a file that's modified more than 2 days ago but less than 5 days ago?

How to find a file that's modified more than 2 days ago but was modified less than 5 days ago by use of any Linux utility ? (4 Replies)
Discussion started by: abdulbadii
4 Replies

2. Shell Programming and Scripting

Grep from file modified one minute ago

Hello, I have a list of files, an example below: -rw-r--r-- 1 smf_oper esg 910773 Jul 6 12:52 am1slc02_ACS_201607061242571_20346.cdr -rw-r--r-- 1 smf_oper esg 995838 Jul 6 12:52 am1slc01_ACS_201607061243125_19895.cdr -rw-r--r-- 1 smf_oper esg 557235 Jul 6 12:52... (5 Replies)
Discussion started by: nms
5 Replies

3. UNIX for Dummies Questions & Answers

Find command to get the modified files past 2 hours

Hello, How to get the modified/created files past 2 hours in Solaris with find command? Thank you. (7 Replies)
Discussion started by: balareddy
7 Replies

4. Shell Programming and Scripting

Display date from twelve hours ago

HI Guys I want to create date folder in unix base on currant date minus 12 hours. Ex: Currant date :07222013 and time is 1 Am So the folder will create date :07212013 (6 Replies)
Discussion started by: pareshkp
6 Replies

5. UNIX for Advanced & Expert Users

find files modified by hours instead of minutes

Is there an easy way to find files modified by hours? If you wanted to find something modified by like 28 hours then I know you could do this: find . -mmin -1440It is pain to break out a calculator and calculate in minutes. Could you do something similar to this? I know I don't have the right... (1 Reply)
Discussion started by: cokedude
1 Replies

6. Shell Programming and Scripting

how to list files between last 6 hours to 3 hours

Hi Frens, I want to list some files from a directory, which contains "DONE" in their name, i am receiving files every minute. In this i want to list all the files which are newer than 6 hours but older than 3 hours, of current time i dont want my list to contain the latest files which are ... (4 Replies)
Discussion started by: Prat007
4 Replies

7. Shell Programming and Scripting

Finding files which are modified few mins ago

Hi All, I have a requirement to find out the files which are modified in the last 10 minutes. I tried the find command with -amin and -mmin options, but its not working on my AIX server. Can anyone of you could help me. Thanks in advance for your help. Raju (3 Replies)
Discussion started by: rajus19
3 Replies

8. Shell Programming and Scripting

command unix to list all files created since n month ago

Hello, I want to list all files that were created since 3 month ago. it exist a unix command to do it ? thank you (8 Replies)
Discussion started by: yacsil
8 Replies
Login or Register to Ask a Question