list the file created before 24 hours using ls command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting list the file created before 24 hours using ls command
# 1  
Old 09-11-2007
list the file created before 24 hours using ls command

I want to list the files created before past 24 hours using ls command.

please help me on this
# 2  
Old 09-11-2007
Using ls

Don't think you can using ls

Look at using find with the -ctime switch

It would be something like

find <dir> -ctime n -exec ls -l {} \;

the n refers to files whoses status has changed n x 24 hours ago
# 3  
Old 09-11-2007
With zsh:

Code:
ls *(mh+24)


Where "files" = plain files, dotfiles, dirs, special files etc.
# 4  
Old 09-11-2007
How can i rollback the deleted file in UNIX?

Hi,

I am using the remote UNIX server, i have used "rm" command in my unix bin promt, all files are deleted from the bin folder, So, Now i want to rollback the deleted files in my UNIX server. how can it possible?

Thanks in advance.

Thanks,
Siva.P
Bangalore
India.
# 5  
Old 09-11-2007
you can do that with find command

find . -type d ! -name '.' -prune -o -type f -mtime +1 -print
# 6  
Old 09-11-2007
Java

Quote:
Originally Posted by quintet
you can do that with find command

find . -type d ! -name '.' -prune -o -type f -mtime +1 -print
Can you please explain the above command - what each attribute will do?

With Regards
Dileep Pattayath
# 7  
Old 09-11-2007
Yeah Sure...

find . -type d ! -name '.' -prune -o -type f -mtime +1 -print

As you know, find command will start from the directory u have mentioned and will descend into the subdirectories..

What I assumed from the question was.. i should display all the files in the current directory that are created before a day...

the first attribute list

-type d ! -name '.' -prune

if the type is a direcorty ('d' ) and if it is not current ('.') then do not descend into it...

-o or option

-mtime +1

modification time more than a day or more than 24 hours..

you can also use -ctime if u wanna keep track of inode changes as well...

-print - will print the file name
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get filelist in a folder which is created in last x hours

Hi , I am looking for some help in getting the list of files matching some pattern in a folder and those were created in last X hours. Please help. Thanks in advance. (1 Reply)
Discussion started by: Anupam_Halder
1 Replies

2. Shell Programming and Scripting

List of Running Jobs In Last 4 Hours

Hi Experts, Please help me in this. I am trying this code on AIX 5.3. I need list of jobs that executed in last 4 hours. I have a schedule on this script - cron executes it and sends mail to me for every 2 hours. I have a Job time and have around 100 jobs those execute daily. What all i need... (2 Replies)
Discussion started by: rajubollas
2 Replies

3. Shell Programming and Scripting

Select only the files created in the last 24 hours

Hi There I am trying to create a shell script (.ksh) that will be run on AIX 5300-10 to scp files from one server to another. The only files I am interested in are the ones that were created in the last 24 hours of whenever the script was run. There are numerous other files in the source... (6 Replies)
Discussion started by: jimbojames
6 Replies

4. Shell Programming and Scripting

Check file created is less than 4 hours or not.

Hi, I need to check some files in one directory whether any files has been created before 4 hours(ie, less than 4 hours from the current time). Can anybody help me out..? Thanks in advance..! (21 Replies)
Discussion started by: Kattoor
21 Replies

5. 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

6. UNIX for Dummies Questions & Answers

Finding a file created within the last 24 hours

which out of atime, ctime, or mtime are the closest to diplaying only the files created within the last 24 hours. is it even possible to find only the files created in the last 24 hours, because I heard that unix files don't hold the creation time as a property of the file. (3 Replies)
Discussion started by: raidkridley
3 Replies

7. Shell Programming and Scripting

Files created in last 24 hours

I need a script which list the files which is starting with the word heap*** and that is created before past 24 hours.I need the script using find command. please help me on this. (1 Reply)
Discussion started by: jayaramanit
1 Replies

8. Solaris

command to list files that are created before some date

Can you please let me know the command to list the files that are created before some date, this we want to use for the following Eg: Move all the files that got created before 2006 to new folder in Solaris (3 Replies)
Discussion started by: csreenivas
3 Replies

9. Shell Programming and Scripting

I want to get the file which created the error when the find command was run

I want to get the file which created the error when the find command was run ? I am wrote a script to mail a list of files whose file size is ge than 0 and returns 0 but wen it finds a folder with only empty files it exits as 1. i need to modify it so that the return for this is also 0 (but it... (1 Reply)
Discussion started by: guhas
1 Replies

10. 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