LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 05-19-2011, 07:55 AM   #1
albicocca
LQ Newbie
 
Registered: May 2011
Location: Italy
Distribution: Ubuntu
Posts: 3

Rep: Reputation: Disabled
find


Hi,

I've setup a samba share with RecycleBin option.
However, there is no cleanup and soon will saturate free space.

I'm trying to plan a command that each week clean the content of those dir or the directory itself.

The dir tree is like /home/ :
  • user1
    • Dir1
    • Dir2
    • RecycleBin
  • user2
    • Dir1
    • Dir2
    • RecycleBin
  • samba
    • groups
    • netlogon
    • profiles
    • shares
      • share1
        • Dir1
        • Dir2
        • RecycleBin
      • share1
        • Dir1
        • Dir2
        • RecycleBin
      • share3
        • Dir1
        • Dir2
        • RecycleBin

I think find is the easy way.
Further more I wish some of those dir are excluded: in the following example "mango" directory.

Code:
find . -name mango -prune -o -name 'RecycleBin' -type d -exec rm -rf {} \;
If works fine but I get an error message:

Code:
rickyx@Balenotterax:~/Scrivania/testrb$ find . -name mango -prune -o -name 'RecycleBin' -type d -exec rm -rf {} \;
find: "./user 3/RecycleBin": File o directory non esistente
find: "./user 2/RecycleBin": File o directory non esistente
find: "./user 1/RecycleBin": File o directory non esistente
rickyx@Balenotterax:~/Scrivania/testrb$
I can't figure out where I'm wrong.

To be careful to all possible situations I'm testing this line in directory with spaces in names. I know is ugly and ... and ... but users are just used to and they don't care about me And, having this line working for spaces I can use it for other situations other than shares.

File o directory non esistente = File or directory does not exist

Thank you,
Ricky

Last edited by albicocca; 05-19-2011 at 08:03 AM.
 
Old 05-19-2011, 06:30 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
I don't think you've done anything wrong - find is trying to report on the directory after it's been deleted and can't find it. If you're happy that the script is working properly now, you could just dump the error output by adding " 2>/dev/null" to the end of the command
 
Old 05-19-2011, 06:37 PM   #3
albicocca
LQ Newbie
 
Registered: May 2011
Location: Italy
Distribution: Ubuntu
Posts: 3

Original Poster
Rep: Reputation: Disabled
I' thought that pruning was wrong.
I'll test on the server itself and report the result.

Thank you,
Riccardo
 
Old 05-19-2011, 08:25 PM   #4
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,604

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
Hi,

you can avoid those error messages by using find's -delete option instead or the -depth option.
Simplified example:
Code:
find /some/path -depth -name 'some_name' -type d -exec rm -rf '{}' \;
# or
find /some/path -name 'some_name' -type d -delete
 
  


Reply

Tags
find


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Find URL in Debian package index via awk/sed (=find a line, then search from there) maddes.b Linux - Software 11 06-28-2013 07:37 AM
linux find to find files with multiple patterns subu_s Programming 6 12-15-2010 12:15 AM
Find with -exec argument - not giving proper output..how to find... hinetvenkat Linux - Server 4 01-25-2010 06:19 AM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM
Can`t find C-compiler in Debian ,or at least can`t find one that can make executables hemmelig Linux - Software 4 05-26-2008 03:07 AM


All times are GMT -5. The time now is 04:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration