Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-23-2009, 04:02 AM   #1
Registered: Oct 2007
Posts: 160

Rep: Reputation: 30
ls .* does not give the expected result

The wild card * expands filenames .But ls .* is expected to show only hidden files but why does it also shows the files inside the hidden directories.where as ls -ad .* shows only the hidden files.

Thank You
Old 04-23-2009, 04:17 AM   #2
LQ Guru
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
That's the same behaviour you'd expect from any ls that includes directory names. Try ls * for example, and you'll get a similar result for non-hidden directories.
Old 04-23-2009, 06:24 AM   #3
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
Now i got it .If a directory is given as argument to ls the files inside directory is listed.similarly * expands all the hidden directories and hence i get the files inside it.
Old 04-23-2009, 06:50 AM   #4
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
ls | grep ".*"

ls a*
lists all files starting with "a" AND the contents of all directories starting with "a"


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
any character matching doesn't yield expected result in PERL gaynut Programming 4 09-26-2008 01:04 AM
new to slackware 9.1, not what i expected digdug4life Slackware 4 02-11-2007 01:11 PM
"who" not giving the expected result rblampain Linux - Newbie 2 11-17-2004 04:06 AM
Fluxbox...not quite what I had expected HoosTrax Linux - Software 12 02-17-2004 11:49 PM
Script Problem - Does not give expected results Jose Muņiz Linux - General 3 07-12-2003 10:10 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:14 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration