Solved

ls command in solaris

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix/bash: scripted arithmetic 13 101
Powershell script explanation 10 63
How do disable only TLSv1.0 in Oracle Sun One 7.1 Server 9 109
AD Cleanup by EmployeeID 11 62
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…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…

821 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