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
  Search this Thread
Old 03-11-2012, 09:48 AM   #16
sysmicuser
Member
 
Registered: Mar 2010
Posts: 353

Original Poster
Rep: Reputation: 0

@grail.

Here is output from my system.
Code:
[user01@centos-flash test]$mkdir -p do_not_delete
[user01@centos-flash test]$mkdir -p do_not_delete_later
[user01@centos-flash test]$find -depth -path './do_not*' -prune -o -print|wc -l
384
[user01@centos-flash test]$find -depth -path './do_not*' -prune -o -print|grep "do_not"
./do_not_delete
./do_not_delete_later
[user01@centos-flash test]$

GNU find version 4.2.27
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION SELINUX
 
Old 03-11-2012, 11:12 AM   #17
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,530

Rep: Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897
What is the output for:
Code:
ls -l do_not*
It is an older version of find, perhaps try placing the directory in:
Code:
find . -depth -path './do_not*' -prune -o -print|grep "do_not"
 
1 members found this post helpful.
Old 03-12-2012, 09:04 AM   #18
sysmicuser
Member
 
Registered: Mar 2010
Posts: 353

Original Poster
Rep: Reputation: 0
@grail.

Here we go.
Code:
[user01@centos-flash test]$ls -l do_not*
do_not_delete:
total 0

do_not_delete_later:
total 0
[user01@centos-flash test]$
There are the directories which we need to eliminate while testing not files.

I gather you are believe that these are files..?

Interesting observation.

Code:
[user01@centos-flash test]$find . -depth -path -not -name './do_not*' -prune -o -print|grep "do_not"
find: warning: Unix filenames usually don't contain slashes (though pathnames do).  That means that '-name ./do_not*' will probably evaluate to false all the time on this system.  You might find the '-wholename' test more useful, or perhaps '-samefile'.  Alternatively, if you are using GNU grep, you could use 'find ... -print0 | grep -FzZ ./do_not*'.
./do_not_delete
./do_not_delete_later
[user01@centos-flash test]$find . -depth -path -prune -o -print|grep -FzZ ./do_not*
[user01@centos-flash test]$
That means if I use grep with -FzZ switch I bloody don't get anything! ?

Why can't we use -not -name switch in above find command?
 
Old 03-12-2012, 10:50 AM   #19
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,530

Rep: Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897
Quote:
Why can't we use -not -name switch in above find command?
Because -path should receive a path and it does not it receives -not -name. Also, using name will not stop a directory from being searched, only that the name is omitted (if used correctly).

Do I guess correctly that the following also yields all folders:
Code:
find . -depth -type d -path -prune -o -print
 
1 members found this post helpful.
Old 03-13-2012, 05:05 AM   #20
sysmicuser
Member
 
Registered: Mar 2010
Posts: 353

Original Poster
Rep: Reputation: 0
Thnaks for that grail.

Yes
Quote:
find . -depth -type d -path -prune -o -print
this one yield all folders, so how should it elimiate do_not_delete and do_not_delete_later directories?
 
Old 03-13-2012, 07:25 AM   #21
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,530

Rep: Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897
Code:
find . -depth -type d -path '*do_not*' -prune -o -print
 
1 members found this post helpful.
Old 03-13-2012, 07:34 AM   #22
sysmicuser
Member
 
Registered: Mar 2010
Posts: 353

Original Poster
Rep: Reputation: 0
Not sure why it is becoming an interesting challenege, nope it still yeilds those two crappy directories
 
Old 03-13-2012, 09:25 AM   #23
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,530

Rep: Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897
Well I guess it is to do with your version of find, so the simplest solution would be:
Code:
find . -depth -type d | grep -v 'do_not*'
 
1 members found this post helpful.
Old 03-13-2012, 03:49 PM   #24
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
I'm with grail on this one ... what version of find are you using?

And, not that I recall any incident with this, what file-system are
those residing on, just for completeness sake?
Code:
find
.
./ab
./ab/t5
./ab/do_not_delete
./ab/t8
./ab/do_not_delete_later
./ab/t6
./ab/t2
./ab/t2/b1
./ab/t2/b1/b12
./ab/t2/b1/b11
./ab/t2/s1
./ab/t3
./ab/t9
./ab/t9/z1
./ab/t9/z2
./ab/t7
./ab/t7/x1
./ab/t7/x1/x11
./ab/t7/x1/x12
./ab/t1
./ab/t4

find . -depth -path '*do_not*' -prune -o -print
./ab/t5
./ab/t8
./ab/t6
./ab/t2/b1/b12
./ab/t2/b1/b11
./ab/t2/b1
./ab/t2/s1
./ab/t2
./ab/t3
./ab/t9/z1
./ab/t9/z2
./ab/t9
./ab/t7/x1/x11
./ab/t7/x1/x12
./ab/t7/x1
./ab/t7
./ab/t1
./ab/t4
./ab
.

Cheers,
Tink
 
1 members found this post helpful.
Old 03-14-2012, 08:19 AM   #25
sysmicuser
Member
 
Registered: Mar 2010
Posts: 353

Original Poster
Rep: Reputation: 0
Okay, can one of you tell me what is version of find program on your OS, also please let me know what is your distro and release.

Many Thanks
 
Old 03-14-2012, 08:36 AM   #26
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,530

Rep: Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897
Mint 12 and find 4.4.2
 
Old 03-14-2012, 08:43 AM   #27
sysmicuser
Member
 
Registered: Mar 2010
Posts: 353

Original Poster
Rep: Reputation: 0
Thanks for that grail.

I can definitely tell that issue is resolved and script works wonderful but a new issue has cropped out.

I did script as crontab job (for trial run running every minute) I am getting error and I am not getting error in my inbox

If I try to do cat on file /var/spool/mail/user01 getting error like,

Code:
syntax error near unexpected token `<'
But I try to run the sam script with ./ it works beautiful without any issues.

command is as follows, seems like I need to chase unix boys tomorrow!

Code:
done< <(find . -type d -depth -path  -prune -o -print |grep -v "do_not*")
It is giving error here....

crontab is running with my useras user id....
 
Old 03-14-2012, 11:20 AM   #28
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,530

Rep: Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897
Why do you have the -path ... parts still in there? See post #23 for all that needs to be there. Not sure if this will fix the issue or not.
 
Old 03-14-2012, 10:58 PM   #29
sysmicuser
Member
 
Registered: Mar 2010
Posts: 353

Original Poster
Rep: Reputation: 0
@grail

the final piece of code is as follows.

Code:
while read -r path
do
    [[ $last == $path ]] || p4 diff -f $path 2>&1 | tee -a $LOG_FILE
    last=${path%/*}
done< <(find . -depth -type d | grep -v 'do_not*')
Interesting thing is script executes without any problem until I schedule it though crontab, where I get failure...

Code:
error code is like it complains of "<" character
line 24: syntax error near unexpected token `<'
line 24: `done< <(find . -depth -type d | grep -v 'do_not*')'
 
Old 03-15-2012, 02:22 AM   #30
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,530

Rep: Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897
hmmm ... please show crontab entry, how its called?
 
  


Reply


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call a array dynamically into a script subbuyt Programming 7 09-08-2011 06:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration