Solved

ls command in solaris

Posted on 2013-06-06
2
388 Views
Last Modified: 2013-06-06
Greetings,
I have this command call in a solaris ksh call

root=$(ls -Al $base/Source |grep xml |wc -l)

is there a way to do a ls that counts xml the source and all of the subfolders?

This ls -AL just checks Source.  I want to know how many xml files there are in the Source and the subfolders inside Source.

Can this be done?
Thanks
0
Comment
Question by:Evan Cutler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39225958
The tool of choice is find.

If your XML files all end in ".xml" :

COUNT=$(find $base/Source  -type f  -name "*.xml" |wc -l)

echo $COUNT

But you can go with ls and its "-R" (recursive) flag, if you prefer:

COUNT=$(ls -AlR $base/Source  | grep xml |wc -l)

echo $COUNT
0
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 39226015
perfect, thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question