Need to skip lost+found when using find
Solution 1
Just do:
find /media/drv -name lost+found -prune -o -type f -exec echo '{}' ';'
In general it is a very very bad idea to redirect stderr to /dev/null. The whole point of stderr is to show unexpected errors. If you are expecting a certain error then construct your command to avoid it.
Solution 2
The find
command does not exit on permission problems as far as I know, it may just not be finding any files for a different reason. What I can suggest is to eliminate stderr so that you don't get misleading messages in the output, and to test the command using echo
replacing rm -rf
, i.e.,
find /media/drv/ -type f -mtime 7 -exec echo {} \; 2> /dev/null
This should list the files that would be removed in your final version with rm -rf
. If you really want to skip the lost+found
directory (which should not be necessary), use:
find /media/drv/ -type f -mtime 7 -not -wholename "*lost+found*" -exec echo {} \; 2> /dev/null
Related videos on Youtube
mrana
Updated on September 18, 2022Comments
-
mrana over 1 year
Let us say i have a page http://www.abc.com/xyz.html and i am going to access this page in two ways
- simple as it is
- I will append some stuff to the url e.g. http://www.abc.com/xyz.html?nohome by just putting the value ?nohome manually in the code.
Now i will add some javascript code something like this
$(document).ready(function () { if (location.search=="?value=nohome") { // wanna hide a button in this current page } else { // just show the original page. } });
Any help will be appreciated.
-
Felix Kling about 12 yearsWhat is your particular question/problem? How to hide an element? api.jquery.com/hide
-
Josip Rodin over 8 yearsGNU find has the
-delete
option so you don't have to exec rm there
-
Richard Holloway over 12 yearsI think it is probably better to use
-not
option onfind
than to delete the lost+found directory, it will just get recreated when fsck runs anyway. See serverfault.com/questions/6753/… -
mrana about 12 yearsU know i was trying nearly same thing from last 2 hours and no results but u seems lucky to me :) thanks
-
Josip Rodin over 8 yearsThere are ample reasons people may want to skip over lost+found. For example, you have a partition where an unprivileged user is allowed to save files (in the partition root), and a cron job that wants to clean those files up. You obviously want to run the cron job as the same unprivileged user, but it will fail to descend into the lost+found directory and produce spurious errors. Eliminating all stderr output because of that one specific circumstance is not a good idea.
-
Josip Rodin over 8 yearsfind has the
-print
option so you don't have to exec echo there. It should also be noted that the default option is to print, but be careful because of-prune
- when that is in place, an explicit-print
is required, otherwise it doesn't actually prune anything from the output, it prints everything that matched.