The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help-prompt for path and take this as input in find command bsandeep_80 UNIX for Advanced & Expert Users 7 01-21-2009 04:49 PM
create PATH from find command output rein UNIX for Dummies Questions & Answers 3 04-01-2008 08:35 AM
how to find the path of a file? wrapster Shell Programming and Scripting 3 03-26-2008 10:31 AM
Find a file in sub-directories.. o/p just the path pranavagarwal Shell Programming and Scripting 3 11-23-2007 01:50 AM
How would I make a find command NOT show the path of a file? LordJezo Shell Programming and Scripting 1 10-01-2004 07:01 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
  #1 (permalink)  
Old 02-15-2008
abhilashnair abhilashnair is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 13
command to find the path of a file

What is the command to find the path of a file if we know the file name and the root directory where the file resides..

For eg. if a file abc.dat resides in /home/mydir/myfiles/. I am looking for a command which will be fired from / directory, takes abc.dat as input and display the path of abc.dat as output
  #2 (permalink)  
Old 02-15-2008
happy.tripathy happy.tripathy is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 2
Try this :

find / -name 'abc.dat'
  #3 (permalink)  
Old 02-15-2008
abhilashnair abhilashnair is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 13
It works. But it also returns many other lines not at all related to the filename which I am giving as input
for eg: if i give command as find /home -name abc.dat it returns the output as given below. Many unwanted file names in the output

find: <filename>: Value too large to be stored in data type
find: <filename>: Value too large to be stored in data type
/home/mydir/myfiles/abc.dat - (This is the only info what I want )
find: <filename>: Value too large to be stored in data type
find: <filename>: Value too large to be stored in data type
find: <filename>: Value too large to be stored in data type
find: <filename>: Value too large to be stored in data type
find: <filename>: Value too large to be stored in data type
find: <filename>: Value too large to be stored in data type
find: <filename>: Value too large to be stored in data type

In the above output all lines except one which i have indicated are unwanted. <filename> does not even match or has any similarity with abc.dat

Why is it so?
  #4 (permalink)  
Old 02-17-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Find is reporting an error. Just redirect stderr to /dev/null to ignore these if you don't care about them:

Code:
find / -type f -name 'abc.dat' 2> /dev/null

(bourne compatible shell)
Closed Thread

Bookmarks

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

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




All times are GMT -4. The time now is 04:25 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0