What difference does * make here ? (ls command question)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers What difference does * make here ? (ls command question)
# 1  
Old 08-28-2012
What difference does * make here ? (ls command question)

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.

Code:
 -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

Code:
$ 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 *




Code:
$ 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

# 2  
Old 08-28-2012
Quote:
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.
And so the difference would have been clear if you did an ls -ld * versus ls -l * Smilie
This User Gave Thanks to vbe For This Post:
# 3  
Old 08-29-2012
Have you tried:
Code:
ls -lad *

Or if that doesn't work on you O/S as a non-root user (I can't test it from here):

Code:
 ls -lad .??* *


Last edited by vbe; 08-30-2012 at 06:20 AM.. Reason: typo: a slash missing...
This User Gave Thanks to methyl For This Post:
# 4  
Old 08-29-2012
The difference becomes clear when you do echo *

The shell substitutes before ls -d is run, turning * into a list of names.

Last edited by Corona688; 08-29-2012 at 07:46 PM..
This User Gave Thanks to Corona688 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Changes in dhcpd.conf do not make a difference in DHCP service behaviour

Hi Experts, Our DHCP server currently answers the DHCP Discover requests from ServerX. In our dhcpd.conf file there are parameters defined for ServerX. Now we introduced some additional Servers into the network and want them to get service from the same DHCP server. Similar configuration... (13 Replies)
Discussion started by: ekorgur
13 Replies

2. UNIX for Advanced & Expert Users

Pam.d and make difference between AD User and local user on Linux

Hello, i configured rhel linux 6 with AD directory to authorize windows users to connect on the system and it works. i have accounts with high privileges (oracle for example) if an account is created on the AD server i would to block him. I looked for how to do, for the moment all the... (3 Replies)
Discussion started by: vincenzo
3 Replies

3. UNIX for Dummies Questions & Answers

Make Utility Question

Hello, I'm a recent convert to UNIX and I'm attempting to understand exactly how the make utility is working under the hood. Now, I understand that each rule has a target, dependencies, and update command, but the thing I'm confused about is exactly how the utility is determining when to... (1 Reply)
Discussion started by: kramer_102
1 Replies

4. UNIX for Dummies Questions & Answers

In AIX, what is the difference between installp and make install?

I've used installp to install packages but when is it ideal to use make install? Havent had the opportunity to use this yet. (2 Replies)
Discussion started by: NycUnxer
2 Replies

5. UNIX for Dummies Questions & Answers

Difference between configure/make/make install.

Hi, While installation of apache on linux, we perform the below tasks. 1) Untar 2) configure 3) make 4) make install. I wanted to understand the difference and working of configure/make/make install. Can any one help me understanding this? Thanks in advance. (1 Reply)
Discussion started by: praveen_b744
1 Replies

6. Solaris

make sure HA server no difference contents

hello there. I would like to know how can I make sure HA server have exactly same contents. for example at timestamp 1 (before start install oracle product ) assume the both server have exactly same contents. at timestamp 2 I install Oracle product at both server, hope... (3 Replies)
Discussion started by: qyxiell
3 Replies

7. Shell Programming and Scripting

difference between .make and .mak file

Hi All, In our project i could see .make files and some .mak file. The build rules and the related commands been written in make file. All the project directory specific thing been written in .mak file and the project directories and makefiles are present in the subdirectories related to the... (0 Replies)
Discussion started by: rvan
0 Replies

8. UNIX for Dummies Questions & Answers

What's the difference between PMake and GNU Make?

My system is ubuntu, can I use PMake ? (0 Replies)
Discussion started by: meili100
0 Replies

9. UNIX for Dummies Questions & Answers

Will userids make a difference in performance?

I have nearly 10 users who login into the HP server (D series, HP UX 10.20) with the same UNIX user name, "liveuser", and they start the UNIX based transactions. If I create separate UNIX user-ids for all the 10, will the system performance improve? (1 Reply)
Discussion started by: augustinep
1 Replies
Login or Register to Ask a Question