grep isn't working correctly
It doesn't work because you need to tell
.* is the actual pattern you're looking for.
grep '.*' -c list3
If you don't use the single quotes, your shell will expand
.* to the names of every file in your directory. This is called Filename Expansion. For example
a.txt b.txt, so
grep will see:
grep a.txt b.txt -c list3
Since single quotes prevent expansion from happening, this is the way to go here.
grep command is wrong:
By the way, you're going the wrong direction with the pattern here. The period
. in a regular expression matches any character, and not the literal dot. See the
man page for more info. So your regex currently says: "find any character and then a sequence of any character". Quite redundant.
If you actually mean to match:
[dot] [anything else]
… you need to escape the dot:
find command could be improved:
I don't know what you mean to get rid of by
\( ! -iname ".*" \)
find command will prefix any file with the dot for the current working directory, thus you won't remove anything here. You could have just run:
find . -maxdepth 1 -type f