Solved

ls command in solaris

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now