Register a domain and help support LQ
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 09-08-2008, 12:04 AM   #1
Registered: Jul 2005
Distribution: Arch
Posts: 159

Rep: Reputation: 31
counting files in multiple directories (zsh)

I can do this:
ls /home/Berticus/something/{one,two,three}/test | wc -l
However, if I try to do this:
echo $BASEDIR/{$DIRS}/test
ls $BASEDIR/{$DIRS}/test | wc -l
It tells me
ls: cannot access /home/Berticus/something/{one,two,three}/test: No such file or directory
Why is it being treated so literally? I tried escaping the brackets as well, but that didn't help at all. I also tried simplifying it to:
ls $DIRS | wc -l
And I still got the same results
Old 09-08-2008, 01:32 AM   #2
Registered: Feb 2006
Distribution: Fedora
Posts: 341
Blog Entries: 3

Rep: Reputation: 38
I'm testing this in bash, and I used this link as reference. It works if I put DIRS as follows:
bash-2.05b ~/scrap$ DIRS=$(echo ~/scrap/{one,two,three}/)
bash-2.05b ~/scrap$ ls $DIRS|wc
       5       3      88
Ought to work the same way in zsh too, let us know if it doesn't.

Last edited by indeliblestamp; 09-08-2008 at 01:34 AM. Reason: removed minor code
Old 09-08-2008, 02:32 AM   #3
Registered: Jul 2005
Distribution: Arch
Posts: 159

Original Poster
Rep: Reputation: 31
yeah, I realized it insurmountably better to put my subdirectories in question in a separate array if I wanted the base directory to be in a separate variable.

arungoodboy, that worked wonderfully.


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
tar multiple files in different directories... visitnag Linux - Desktop 1 04-13-2008 11:02 PM
List all files in multiple directories haiders Linux - Newbie 6 05-10-2007 12:05 PM
Change text in multiple files in multiple directories vivo2341 Linux - General 5 11-27-2006 08:16 PM
Help I need help tarring multiple files in multiple directories VisionZ Linux - Newbie 28 03-25-2004 05:25 PM
Counting SLOC of multiple files uraja Linux - Newbie 1 09-12-2003 07:12 PM

All times are GMT -5. The time now is 11:04 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