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!

find . -name "test*" |awk -F/ '{print $NF}'

hi,

i hope the below will work for you,

basename `find .....`

basename ---> diplays only the file name.

thanks this worked great!

any good ideas on an easy way to filter out the . and .. ?

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

@madankumar
Please check your original thread:

No need to hijack this one :smiley:

pooga17's solution works, so where is the doubt... you just have to modify the starting path and the name you are looking for...

1 Like