The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find command - First file only neeto Shell Programming and Scripting 1 04-23-2008 02:47 PM
how to find a file named vijay in a directory using find command amirthraj_12 UNIX for Dummies Questions & Answers 5 10-25-2006 02:39 PM
How to use the command Tar to find a file steiner UNIX for Advanced & Expert Users 2 08-18-2005 06:13 AM
how to find a file in UNIX without find command? bluo Shell Programming and Scripting 3 09-24-2003 08:47 PM
Is a simple one command to find a file? E-Quality UNIX for Dummies Questions & Answers 11 09-18-2001 09:19 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-03-2008
Registered User
 

Join Date: Nov 2007
Posts: 9
get file name from find command

how can i get the find command to display the filename without the path.

example:

find /tmp/test

/tmp/test1
/tmp/test2
/tmp/test3

should return

test1
test2
test3

i'm using bash.

also, whats the best way to ignore the . and .. directories?

thanks!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-03-2008
Registered User
 

Join Date: Dec 2007
Posts: 9
find . -name "test*" |awk -F/ '{print $NF}'
Reply With Quote
  #3 (permalink)  
Old 03-03-2008
Registered User
 

Join Date: Feb 2008
Posts: 21
hi,

i hope the below will work for you,

basename `find .....`

basename ---> diplays only the file name.
Reply With Quote
  #4 (permalink)  
Old 03-03-2008
Registered User
 

Join Date: Nov 2007
Posts: 9
Quote:
Originally Posted by pooga17 View Post
find . -name "test*" |awk -F/ '{print $NF}'
thanks this worked great!

any good ideas on an easy way to filter out the . and .. ?
Reply With Quote
  #5 (permalink)  
Old 07-18-2008
Registered User
 

Join Date: Jan 2008
Location: Bangalore
Posts: 7
Question

Hi Thanks it is working .... I have doubt

I want to list the files in a particular directory having *.dat without displaying the pathnames.


Ex: /home/usr/local/data
in this directory I have 5 dat files

I want to list the files of this directory with out displaying the path from home directory ..

Plz help me
Reply With Quote
  #6 (permalink)  
Old 07-18-2008
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 729
@madankumar
Please check your original thread:
List the files without directory path

No need to hijack this one

Quote:
Hi Thanks it is working .... I have doubt
pooga17's solution works, so where is the doubt... you just have to modify the starting path and the name you are looking for...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0