<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Dear Rick,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thank you very much.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
When I used the <span style="font-family: "Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 15px; background-color: rgb(255, 255, 255); display: inline !important; color: rgb(81, 167, 249);"><i>systemfunc</i></span><span style="font-family:"Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important">,
 the problem was solved. It seems that I could use the shell language from the systemfunc in ncl script.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important">Million thanks again! Have a good
 day!</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important">Best regards,</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important">Chang</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Microsoft Yahei UI", Verdana, Simsun, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>发件人:</b> Rick Brownrigg <brownrig@ucar.edu><br>
<b>发送时间:</b> 2021年11月30日 20:48<br>
<b>收件人:</b> LIU Chang <cliucv@connect.ust.hk><br>
<b>抄送:</b> ncl-talk <ncl-talk@ucar.edu><br>
<b>主题:</b> Re: [ncl-talk] problem about knowing the files number</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>Hi,</div>
<div><br>
</div>
<div>You can use NCL's systemfunc() (<a href="https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fncl.ucar.edu%2FDocument%2FFunctions%2FBuilt-in%2Fsystemfunc.shtml&data=04%7C01%7Ccliucv%40connect.ust.hk%7C35666a075c174bb5db5508d9b3ffb412%7C6c1d415239d044ca88d9b8d6ddca0708%7C1%7C0%7C637738733089081129%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=aVl7WwnWvCQ4kVtVcsCIqHdRaaRwHH23Ce8I3lYEKQ0%3D&reserved=0" originalsrc="http://ncl.ucar.edu/Document/Functions/Built-in/systemfunc.shtml" shash="jQZHOp5WFeYXUZItZX2XPBF0FPUqcvyB5EHXWOyUT+TWubCGFDzTSyrWxG2ya6bWDUPH5s2iDNrHW2GW3+DIJ4l4Nvd3rcVw4iqDhKjiZC6gFUflQ85r+EFTMZb+Z7OSz5i8W/in+UuBRClyFGZkhXmExJduFwn96HcaivN9PM4=">http://ncl.ucar.edu/Document/Functions/Built-in/systemfunc.shtml</a>):</div>
<div><br>
</div>
<div>Something like:</div>
<div><br>
</div>
<div><span style="color:rgb(0,0,0)">   a = systemfunc("ls diri -l | grep '^-' | wc -l")</span></div>
<div><span style="color:rgb(0,0,0)"><br>
</span></div>
<div><span style="color:rgb(0,0,0)">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 (<a href="https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fncl.ucar.edu%2FDocument%2FFunctions%2FBuilt-in%2Fstr_get_dq.shtml&data=04%7C01%7Ccliucv%40connect.ust.hk%7C35666a075c174bb5db5508d9b3ffb412%7C6c1d415239d044ca88d9b8d6ddca0708%7C1%7C0%7C637738733089091086%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Nw7FCa%2F08rbLtfnDJJrG%2Bn3KdRbNWCeR99pc0ZEsa4c%3D&reserved=0" originalsrc="http://ncl.ucar.edu/Document/Functions/Built-in/str_get_dq.shtml" shash="JndZ0Vl/QQCf0i9tb3wY0wPcFihLWa7NoA/psm07hb4dKar2JkIsXLvKhzD49TrbjVdxBjxFucOfsmf7L/yDbUh/eBK4TW/+EeVCbzd1ALWV7hV0dfi5/g8HROrWfS1u7DECB9ZAK31+B7n7gfP3pemB0VK35zz6aaCx66XsYPY=">http://ncl.ucar.edu/Document/Functions/Built-in/str_get_dq.shtml</a>);
 see the examples for usage.</span></div>
<div><span style="color:rgb(0,0,0)"><br>
</span></div>
<div><span style="color:rgb(0,0,0)">Rick</span></div>
<div><span style="color:rgb(81,167,249)"><br>
</span></div>
<div><span style="color:rgb(81,167,249)"><br>
</span></div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Tue, Nov 30, 2021 at 4:40 AM LIU Chang via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Dear NCL,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I want to know how many files in my one dir based on NCL.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I have known that based on shell, typing  <span style="color:rgb(81,167,249)">a=`</span><span style="color:rgb(81,167,249)">ls diri -l | grep "^-" | wc -l` </span><span style="color:rgb(0,36,81)">​, it will echo a and a is equal to files number.</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="color:rgb(0,36,81)">​</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="color:rgb(0,36,81)">However, when I tried to add the sentence into my ncl script, it showed that
</span><span style="color:rgb(81,167,249)">a=`, </span><span style="color:rgb(81,167,249)">fatal:Syntax Error in block, block not executed</span><span style="color:rgb(0,36,81)">.</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="color:rgb(0,36,81)"><br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="color:rgb(0,36,81)">It will be really appreciated if you could give me some suggestions to solve the problem.</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="color:rgb(0,36,81)"><br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="color:rgb(0,36,81)">Best regards,</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="color:rgb(0,36,81)">Chang LIU</span></div>
</div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.ucar.edu%2Fmailman%2Flistinfo%2Fncl-talk&data=04%7C01%7Ccliucv%40connect.ust.hk%7C35666a075c174bb5db5508d9b3ffb412%7C6c1d415239d044ca88d9b8d6ddca0708%7C1%7C0%7C637738733089091086%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=0OTo1Z3oAygeh5%2BOKlN1PFnO25Dvws2W%2BomBqnamGHw%3D&reserved=0" originalsrc="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" shash="yeSJus4GplEApWwINJ8kzJhA6WvYQAXOlZVlTdkz9asjx7oS8lWM+RSlbYiHqmA4lfJVDP/tooOWcquZPEMXiO9hjA+PpRvKlNmXMQnSJR7TcOM1UKuJorwtZLG02FnXfAdHC9HzvVZhmijfLmcIFwq2CCZVTGbknu2QXapkn2U=" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote>
</div>
</div>
</body>
</html>