0

I've got the following command

find /tmp/sjohal/archivetest > list

However I need the output to show the filenames in the folder without the directory path.

What is the best way to do this?

My current output looks as follows:

/tmp/sjohal/archivetest
/tmp/sjohal/archivetest/test2
/tmp/sjohal/archivetest/test1
/tmp/sjohal/archivetest/test3
/tmp/sjohal/archivetest/list.txt

I only require the output to show the files:

test2
test1
test3
hg8
  • 1,082
  • 2
  • 15
  • 28
Sandeep Johal
  • 399
  • 2
  • 6
  • 16

2 Answers2

0

For all the files in the directory (without subdirectories)

find /tmp/sjohal/archivetest -maxdepth 1 ! -name 'list.txt' -type f -printf "%f\n"
chris
  • 161
  • 5
  • Thanks that seems to have worked except it still includes the output in the list. When I do find /tmp/sjohal/archivetest -maxdepth 1 -type f -printf "%f\n" > out – Sandeep Johal May 15 '15 at 13:07
0

Try using ls command: ls /tmp/sjohal/archivetest > list.txt