Solved

delete file

Posted on 2013-05-25
8
294 Views
Last Modified: 2013-06-04
[oracle@term1 admin]$ ls -lart
total 40
-rw-r--r--  1 oracle oinstall  187 May  9  2007 shrept.lst
drwxr-xr-x  2 oracle oinstall 4096 Feb  2 13:47 samples
drwxr-xr-x 11 oracle oinstall 4096 Feb  2 13:57 ..
-rw-r--r--  1 oracle oinstall  223 Feb  2 14:04 sqlnet.ora
-rw-r-----  1 oracle oinstall  738 Feb  8 00:43 tnsnames.ora~
-rw-r--r--  1 oracle oinstall  382 Mar 13 20:45 listener.ora~
-rw-r-----  1 oracle oinstall 1036 Mar 13 23:03 tnsnames.ora
-rw-r--r--  1 oracle oinstall  382 May 19 21:45 listener.ora
drwxr-xr-x  4 oracle oinstall 4096 May 25 09:06 .
drwxr-xr-x  2 oracle oinstall 4096 May 25 09:06 admin
[oracle@term1 admin]$ cd 7~

Is there any command just to delete that all files created on May 25
rm -rf  is applicable to admin but one of the file is hidden
0
Comment
Question by:walkerdba
8 Comments
 
LVL 29

Expert Comment

by:Randy Downs
ID: 39196793
Try piping your ls into rm \.*

http://www.linuxforums.org/forum/red-hat-fedora-linux/69038-how-delete-hidden-files.html

u can remove the hidden files by this command

$ rm \.*
0
 
LVL 28

Accepted Solution

by:
serialband earned 500 total points
ID: 39196967
First you find them.

find . -ctime -1  -exec ls -la "{}" \;

Then you can delete them.
find . -ctime -1  -exec rm "{}" \;
0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 39197237
The posts above assume that May 25th was yesterday (that's what the -1 means). Since you mention rm -rf I assume you want to remove all files anywhere in the tree that were created on 25th May. (As an aside, Linux doesn't track create times, but it does track inode change times which is close. That's what -ctime gives you and as well as file creation it is changed by renaming or moving the file (with mv command)). This command finds by absolute date: find . -type f -newerct 2013-05-25 -not -newerct 2013-05-26. Because it is looking for a newer file, it does not find files modified at exactly 00:00:00 on 25th May - you would need to use '2013-05-24 23:59:59' and '2013-05-25 23:59:59' for that. Assuming you don't need that level of precision, do
find . -type f -newerct 2013-05-25 -not -newerct 2013-05-26 -ls
to see the files you are going to remove, then actually do it
find . -type f -newerct 2013-05-25 -not -newerct 2013-05-26 | xargs rm -f -v
The -v is optional - thought you might like to see the files being removed
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 34

Expert Comment

by:Duncan Roe
ID: 39197238
To only remove files in the current directory
find . -type f -maxdepth 1 -newerct 2013-05-25 -not -newerct 2013-05-26 | xargs rm -f -v
0
 
LVL 19

Expert Comment

by:simon3270
ID: 39198075
I assume you've spotted that the main directory (the "." entry in the listing) was modified on May 25, so all files in that directory will have been forcibly and recursively removed. (yes, I know that "rm -rf ." will usually fail, put if a path is given, it will succeed)

If you aren't removing a directory, don't use "-r" on the rm command, and only use "-f" if you really need to.  Some people always use "rm -rf" even to remove single files that they own, unaware of the dangers.  It's the same mentatlity whcih always uses "kill -9" when a simple "kill" wil suffice and has much safer results.
0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 39198185
-type f restricts to files only - directories will not be considered
0
 
LVL 19

Expert Comment

by:simon3270
ID: 39198571
And you hadn't used "-rf" anyway.  My fault for trying to follow two questions at once with similar answers.

My point is still valid, just not here!
0
 

Author Closing Comment

by:walkerdba
ID: 39219941
yes
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Anything Suspicious in this Report Email on Linux Server 4 47
How can you tell your public IP address without a browser? 9 61
Linux VM 6 86
winscp 000webhost.com 6 43
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now