LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

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


Hi
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
billymayday
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
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
Thanks,
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
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Try:
ls | grep ".*"

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


Reply


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


All times are GMT -5. The time now is 08:54 AM.

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