LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 10-05-2006, 02:51 PM   #1
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Rep: Reputation: 30
ls and regexp


i try:
ls /[a-h]* - lists all root dirs recursively!?

ls -d /[a-h]*
/bin /boot /dev /doc /etc /home
 
Old 10-05-2006, 02:54 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
What do you want to do? list out every directory on your system? If so, try "find -type d /"
 
Old 10-05-2006, 03:03 PM   #3
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
i wonder why ls /[a-h]* lists directories "a" to "h" recursively
 
Old 10-05-2006, 03:10 PM   #4
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Is it *really* recursive, or just one level deeper than you expected? Just "ls" is actually uses does "ls ." as a default, and doing say, "ls /var" is equavalent to "cd /var; ls; cd $OLDPWD".
 
Old 10-05-2006, 03:23 PM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082
It's not really ls doing the listing here though, it's bash. To see the shell wildcard expansion type
echo /[a-h]* then type Esc followed by * (holding down Alt with * should also work)
 
Old 10-05-2006, 03:30 PM   #6
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
.......................................

Last edited by ygloo; 10-05-2006 at 03:31 PM.
 
Old 10-05-2006, 03:31 PM   #7
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
yes ... it descends one level deeper into directory...
i expected to see

Code:
ls /[a-h]*
/bin
/boot 
/dev 
/doc 
/etc 
/home

Code:
 echo /[a-h]*                 
/bin /boot /dev /doc /etc /home
Alt_* :
(arg: 8) and waiting prompt

Last edited by ygloo; 10-05-2006 at 03:45 PM.
 
Old 10-05-2006, 03:42 PM   #8
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082
ls will give a listing of the directory(ies) you put on the command line, or current directory if you put nothing. eg:
Code:
~% ls /usr /media                                                              
/media:
cdrom  cdrom0  floppy  floppy0  usb  usb0

/usr:
bin  games  include  lib  lib64  libexec  local  sbin  share  src  X11R6
Since type /[a-h]* is equivalent to typing /bin /boot /dev /doc /etc /home (since bash expands it before sending to ls) you get the listing of all of those directories.

Alt+* means you have to hold down shift when typing the 8 key or use the keypad
 
Old 10-05-2006, 03:50 PM   #9
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
now tux understand..

ls /[a-h]* = ls /bin /boot /home...

Last edited by ygloo; 11-18-2006 at 04:53 PM.
 
  


Reply

Tags
ls, regexp



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
regexp help cliff76 Linux - Newbie 3 03-07-2008 02:15 PM
regexp stomach Linux - Software 7 02-15-2006 06:33 PM
little help for regexp EmOuBi Linux - Newbie 6 08-06-2005 02:19 AM
Regexp question scuffell Programming 4 04-30-2005 03:35 AM
regexp help ... pld Programming 1 03-15-2005 03:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:07 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration