Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ls command in solaris

Posted on 2013-06-06
2
Medium Priority
?
396 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 2000 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

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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

688 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