[ncl-talk] problem about knowing the files number

Rick Brownrigg brownrig at ucar.edu
Tue Nov 30 05:48:13 MST 2021


Hi,

You can use NCL's systemfunc() (
http://ncl.ucar.edu/Document/Functions/Built-in/systemfunc.shtml):

Something like:

   a = systemfunc("ls diri -l | grep '^-' | wc -l")

Note the use of single quotes around the grep RE. There's not a great way
to escape double quotes in string literals. To do so, you need the
str_get_dq() function (
http://ncl.ucar.edu/Document/Functions/Built-in/str_get_dq.shtml); see the
examples for usage.

Rick



On Tue, Nov 30, 2021 at 4:40 AM LIU Chang via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Dear NCL,
>
> I want to know how many files in my one dir based on NCL.
>
> I have known that based on shell, typing  a=`ls diri -l | grep "^-" | wc
> -l` ​, it will echo a and a is equal to files number.
>> However, when I tried to add the sentence into my ncl script, it showed
> that a=`, fatal:Syntax Error in block, block not executed.
>
> It will be really appreciated if you could give me some suggestions to
> solve the problem.
>
> Best regards,
> Chang LIU
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20211130/cce503d6/attachment.html>


More information about the ncl-talk mailing list