Solaris 10 (korn shell)
I use -d option with ls command , when I want to suppress contents of the subdirectories being listed
when listing all the directories and files in a directory.
This is what man page says about -d option in ls command.
-d If an argument is a directory, lists only its name (not its contents).
Often used with -l to get the status of a directory.
# Creating 2 files and 2 directories for testing
$ pwd
/tmp/stage_dir
$ ls
$ touch a.txt
$ touch b.txt
$ mkdir mysub_dir1
$ mkdir mysub_dir2
$
$ ls
a.txt b.txt mysub_dir1 mysub_dir2
A plain ls -d command will only list just a dot (.) which is understandable because current directory (dot) is just another file and -d option will suppress anything within it from being listed. My question is how the files and directories are listed when an asterik (*) is added . ie. ls -d *
$ ls -d
.
$ ls -dl
drwxrwxr-x 5 oracle oinstall 512 Aug 4 23:41 .
$ ls -d *
a.txt b.txt mysub_dir1 mysub_dir2
$
$
$
$ ls -ld *
-rw-r--r-- 1 oracle oinstall 0 Aug 26 12:01 a.txt
-rw-r--r-- 1 oracle oinstall 0 Aug 26 12:01 b.txt
drwxr-xr-x 2 oracle oinstall 512 Aug 26 12:01 mysub_dir1
drwxr-xr-x 2 oracle oinstall 512 Aug 26 12:01 mysub_dir2