LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-11-2020, 10:14 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
have find to not print, ie. to supress as on lse condition


How do we have find to not print, ie. to supress, when on else condition ?
Code:
find .  -path '*/*t*s' \( -type d -printf "DIR:%p\n" -o -printf "**%p**\n" \) -o -print
                                                    --------^
The pointed out by arrow alternative -printf "**%p**\n" is intended to be instructing suppress it instead"

How to solve it as if it's omitted altogether it'll be printed out? Thanks before
 
Old 12-11-2020, 10:24 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Which else condition?

You print something when a directory is found. Under which circumstances do you not want to print?

To suppress printing for types other than d:
Code:
find . -path ... -type d -printf ...
 
Old 12-12-2020, 05:05 AM   #3
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,832

Rep: Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219
Either the
Code:
 -type d -printf "DIR:%p\n"
or the
Code:
 -printf "**%p**\n"
is true, so the
Code:
 -print
never runs.
So it boils down to
Code:
find . -path '*/*t*s' \( -type d -printf "DIR:%p\n" -o -printf "**%p**\n" \)
Without the 2nd printf
Code:
find . -path '*/*t*s' -type d -printf "DIR:%p\n"
 
Old 12-12-2020, 06:54 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,152

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
ahh print - one of the most awesome manpage every written.

Not to mention most inscrutable - or should that be arcane ?.
 
  


Reply



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
check Negative egrep condition in an if condition novicunix Programming 5 02-02-2013 12:52 AM
[SOLVED] How-to supress output when exit code not 0 ? Linux_Kidd Programming 11 10-24-2011 08:29 AM
[SOLVED] Perl: Condition?print "Is true":print "Is false"; angel115 Programming 2 09-17-2010 06:28 AM
using OR condition in if condition Fond_of_Opensource Linux - Newbie 2 10-20-2006 12:34 AM
Kernel option to supress framebuffer logo? bender647 Linux - Software 1 06-22-2003 11:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:49 AM.

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
Open Source Consulting | Domain Registration