Reputation: 140377
If the glob */
only matches directories, then logically the extglob !(*/)
should match non-directories; but this doesn't work. Is this a bug or am I missing something? Does this work on any shell?
*/
works$ cd /tmp; ls -ld */
drwxr-xr-x 2 seand users 4096 Jan 1 15:59 test1//
drwxr-xr-x 2 seand users 4096 Jan 1 15:59 test2//
drwxr-xr-x 2 seand users 4096 Jan 1 15:59 test3//
!(*/)
$ cd /tmp; shopt -s extglob; ls -ld !(*/)
/bin/ls: cannot access !(*/): No such file or directory
Upvotes: 3
Views: 684
Reputation: 2870
The answer to the specific question has already been given; and I am not sure if you really wanted another solution or if you were just interested to analyze the behavior, but one way to list all non-directories in the current folder is to use find:
find . ! -type d -maxdepth 1
Upvotes: 0