Is it possible to list hidden files without using the characters mentioned above? This means not using any options or the * wildcard as well as some other characters (e.g this is not allowed ls -a
, ls -d
, .!(|.)
, echo .*
etc.).
Is it possible to list hidden files without using the characters mentioned above? This means not using any options or the * wildcard as well as some other characters (e.g this is not allowed ls -a
, ls -d
, .!(|.)
, echo .*
etc.).
find .
will list all files including hidden ones.
Corollary: Somebody thinks it's a good idea to teach about command injection by blacklisting individual characters and possibly even commands in your script. That is actively harmful to your learning about the shell because you end up with hacks like escape characters or relying on Ubuntu-specific default configuration, both of which won't be able to handle special file names.
It actually sounds like whoever came up with this wanted to use eval
for some reason (which is always* a terrible idea) rather than just executing the submitted code or script directly.
The absolutely simplest way to loop over hidden files is
for file in .*
do
my_command "$file"
done
* Or so damn close to always that you'd better have read and understood the entire Bash wiki article about it before even considering using it.