I've checked some answers online, but they do not work when there's a -name parameter in the command (maybe I'm doing something wrong, not sure). What I'd like to do is to list only filenames (not the directory/path), and to complicate more, I have same filename with different extension, so I need to filter the result using -name and -o, the trouble is the suggestions that I saw use either -printf or basename, and those doesn't work well when there's -name *.txt -o name *.pdf. Is there any other way to solve this problem?
Example of my files:
/dir1/dir2/dir3/dir4/
/file1.txt
/file1.pdf
/file1.ods ...etc.
I'm only interested in listing one or more type of file per listing (by using -name to filter my results.
Is it possible to accomplish it using only 1 find command or I have to do it in 2 steps (saving the result in a temporary file, then filter/strip the directory from the temp file)? The result I'm trying to accomplish is a text file with filename per line:
file1.txt
file1.pdf
file1.ods
file2.txt
file2.pdf
etc.
The command I was using is
find /dir1/dir2/dir3/dir4/ -type f -name '*.txt' -o -name '*.pdf' -o -name '*.ods' -printf "%f\n"
I am using GNU find.
Update
It turned out I have to put \(...\), as reminded by αғsнιη
-printfand-name *.txt -o -name *.pdfit'll list only the last one, not both, maybe I'm doing something wrong. I'm not that familiar with Linux.