In general, the empty string does not denote the current directory, neither to shell commands nor in system calls. It did on some older systems, but not on POSIX-compliant systems.
Occasionally you'll find a program which uses the current directory when you pass an empty string and the program expects a directory name. This is sometimes deliberate, and sometimes a side-effect of prepending the current directory's absolute path when the given string does not start with a slash.
The best thing for you would be to leave the
./. It doesn't do any harm.
If the list of files is for
find . … | sed 's!^\./!!'
Note that this mangles some file names containing newlines. This usually isn't a problem for human consumption, and the output of
find isn't suitable for program consumption since it is ambiguous. If you're using
-print0, which is suitable for program consumption, you probably don't care about the
./ prefix anyway.
You can use
find * … instead of
find . …, but note that
find * has a number of defects that make it unsuitable in general:
. is omitted.
- All dot files (files whose name begins with
. or ..`) are omitted.
- If there is a file name in the current directory whose name begins with
- (or a file called
(...), it will be interpreted as an option or predicate by
The first point doesn't matter if your filter excludes the current directory. For the second point, you can use the patterns
..?* .[!.]* * to match all files in the current directory, but you'll need to check whether each pattern matches at least one file and omit it if it doesn't. This is possible but very cumbersome. The last point is a stopper. So
find * may be suitable for quickie command line use, but don't use it in a script.
An alternative approach is to use the shell's recursive globbing facility, e.g.
printf '%s\n' **/*.h
This needs to be activated by
shopt -s globstar in bash and by
set -o globstar in ksh93, and doesn't exist in a basic POSIX shell such as dash. Dot files will not be traversed by default; to include them, first make globbing not ignore dot files with
shopt -s dotglob in bash or
FIGNORE='@(.|..)' in ksh93. Also, if there are no matches, then this command prints the pattern; run
shopt -s nullglob in bash to print an empty line instead, and use the pattern
~(N)**/*.h in ksh.
In zsh, recursive globbing is on by default. Use the glob qualifier
D to include dot files and
N to print an empty line if there are no matches (by default, zsh throws an error if a pattern doesn't match any file). You can use
printf as above or
print -rl -- **/*.h(DN)