How to find files in current folder only?

How do I find files in current folder only?

We are on AIX 5.3, so maxdepth is not supported.

I tried to do this

find /dir1/dir2/dir3/dir4 -prune -type f

to display all files in /dir1/dir2/dir3/dir4 only but it does not show any files.

Somehow the -prune option works for dir3 level only.

if I try to display files in /dir1/dir2/dir3/dir4 then it does not work.

There is "-depth" option, I am copying help desc.

======================
-depth
Always evaluates to the value True. Causes the descent of the directory hierarchy to be done so that all entries
in a directory are affected before the directory itself is affected. This can be useful when the find command is
used with the cpio command to transfer files that are contained in directories without write permission.

printf "%s\n" /dir1/dir2/dir3/dir4/*

This displays any subdir if any under dir4 also.

?

It will display the name, but it will not descend into it.

If you only want files and not directories:

for f in /dir1/dir2/dir3/dir4/*
do
   [ -f "$f" ] && printf "%s\n" "$f"
done

That worked.

I had to delete the file so I added

&& `rm $f`

:b:

Why are you trying to execute the output of `rm $f`?

It should be:

&& rm "$f"

If you just want to delete the files in dir4, why not:

rm  /dir1/dir2/dir3/dir4/* 2>/dev/null

Agreed that I should not use `rm $f` and instead rm $f will also work.

If I try to use

rm /dir1/dir2/* 2 > /dev/null

then it also tries to delete any subdir under it also.

Not rm $f; use rm "$f".

No, it doesn't; rm does not remove directories unless you use the -r option.