Solved

ls command in solaris

Posted on 2013-06-06
2
384 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 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