UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old March 1st, 2005, 03:21 PM
Basil_Fawlty Basil_Fawlty is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 16 Basil_Fawlty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 7 m 7 sec
Reputation Power: 0
Using find command

How would I use find to display the names of all files in the /home subdirectory tree without displaying errors for files I can't read?

Is this correct?

find /home -name * -print 2>/dev/null

Reply With Quote
  #2  
Old March 1st, 2005, 07:36 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,077 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 13 h 40 m 11 sec
Reputation Power: 8
IMPORTANT: which shell are you using? by bourne¦korn¦bash just try:
Quote:
find /home 2>/dev/null

or when working on YOUR home
Quote:
cd ; find . 2>/dev/null

the -print on SVR4 is obsolete
__________________
working on Solaris[5-9], preferred languages french and C.

Reply With Quote
  #3  
Old March 5th, 2005, 02:23 PM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 4 m 36 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
well in bash, you could just do the following:

find /home -name "*" -print | grep -v "Permission denied"



christo

Reply With Quote
  #4  
Old March 7th, 2005, 10:26 AM
andyb1ack andyb1ack is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 60 andyb1ack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 14 sec
Reputation Power: 4
find /home -type f 2>/dev/null
or
find /home -type f -ls 2>/dev/null
or
find /home -type f -exec ls -l {} \; 2>/dev/null


and as guggach pointed out... get relative pathnames by changing to /home first and then doing "find ." (useful for backups...)

Reply With Quote
  #5  
Old March 7th, 2005, 12:18 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,077 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 13 h 40 m 11 sec
Reputation Power: 8
Quote:
Originally Posted by christo
well in bash, you could just do the following:
find /home -name "*" -print | grep -v "Permission denied"

sorry christo, who teached you that?
find /home -name "*" : is a st..*y AND will not find dotfiles
-print IS OBSOLETE (i repeat)
grep -v "Permission denied" NEVER heard about 2>/dev/null

Reply With Quote
  #6  
Old March 7th, 2005, 12:37 PM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 4 m 36 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
Quote:
Originally Posted by guggach
sorry christo, who teached you that?
find /home -name "*" : is a st..*y AND will not find dotfiles
-print IS OBSOLETE (i repeat)
grep -v "Permission denied" NEVER heard about 2>/dev/null



woah easy, dude... it was just a fleeting poke at a solution. Probably it wasn't the best, but it's just what tricked off my fingers at the time.


christo

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Using find command


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway