Ok so, I know ls -a lists files including the hidden ones, and * command includes the elements I want to include. ls -I ".." -I "..." does not work as I have to use ls -a.
What command would I use to list all files and directories, including hidden ones, except . and ..?
See how to glob every hidden file except current and parent directory– steeldriverFeb 2, 2022 at 1:56
GNU ls has
-A, which lists all directory entries except for
-A, --almost-all do not list implied . and ..
$ touch foo bar baz $ ls -A bar baz foo
Otherwise, portably, you can use globs with a case statement:
for dirent in * .*; do case $dirent in .|..) continue ;; *) [ -e "$dirent" ] && printf '%s\n' "$dirent" ;; esac done