 to add 10 over and over for every invocation of d. It stays 20 every time, why?
function d() {
    var c = [10];
    c[0] += 10;
    alert(c[0]); // always 20
}
d(); d(); d(); // supposed to be 20, 30, 40...

A:

You create a new array and assign it to c each time the function is called. That resets it.
Move the assignment so it is outside the function (so it only runs once).
var c = [10];
function d() {
    c[0] += 10;
    alert(c[0]);
}
d(); d(); d(); // will be 20, 30, 40...

But globals are good source of bugs, so it is considered good style to wrap such things in closures to minimise the use of globals.
var d =(function () {
    var c = [10];
    function d() {
        c[0] += 10;
        alert(c[0]);
    };
    return d;
})();
d(); d(); d();

 Q:

What is the meaning of ${arg##/*/} and {} \; in shell scripting

Please find the code below for displaying the directories in the current folder.

What is the meaning of ${arg##/*/} in shell scripting. (Both arg#* and arg##/*/ gives the same output. )
What is the meaning of {} \; in for loop statement.

for arg in `find. -type d -exec ls -d {} \;`
do
  echo "Output 1" ${arg##/*/}
  echo "Output 2" ${arg#*}
done

A:

Adding to @JoSo's helpful answer:
${arg#*} is a fundamentally pointless expansion, as its result is always identical to $arg itself, since it strips the shortest prefix matching any character (*) and the shortest prefix matching any character is the empty string.
${arg##/*/} - stripping the longest prefix matching pattern /*/ - is useless in this context, because the output paths will be./-prefixed due to use of find., so there will be no prefix starting with /. By contrast, ${arg##*/} will work and strip the parent path (
to add 10 over and over for every invocation of d. It stays 20 every meter, why? 
 affair d () { 
     var c = [ 10 ]; 
     c[0 ] + = 10; 
     alert(c[0 ]); // always 20 
 } 
 d (); d (); d (); // supposed to be 20, 30, 40... 

 A: 

 You produce a new array and assign it to c each prison term the routine is called. That reset it. 
 Move the assignment so it is outside the routine (so it only run once). 
 var c = [ 10 ]; 
 function d () { 
     c[0 ] + = 10; 
     alert(c[0 ]); 
 } 
 d (); d (); d (); // will be 20, 30, 40... 

 But globals are good beginning of bugs, so it is considered good dash to wrap such things in closures to minimise the function of globals. 
 var d =( function () { 
     var c = [ 10 ]; 
     function d () { 
         c[0 ] + = 10; 
         alert(c[0 ]); 
     }; 
     return d; 
 }) (); 
 d (); d (); d (); 

  Q: 

 What is the meaning of $ { arg##/*/ } and { } \; in shell scripting 

 Please find the code downstairs for displaying the directories in the current folder. 

 What is the meaning of $ { arg##/*/ } in shell scripting. (Both arg # * and arg##/*/ gives the same output .) 
 What is the meaning of { } \; in for loop statement. 

 for arg in 'find. -type d -exec ls -d { } \; '
 do 
   echo " Output 1 " $ { arg##/*/ } 
   echo " Output 2 " $ { arg # * } 
 done 

 A: 

 Adding to @JoSo's helpful answer: 
 $ { arg # * } is a fundamentally otiose expansion, as its consequence is always identical to $ arg itself, since it strip the short prefix matching any character (*) and the shortest prefix match any character is the empty string. 
 $ { arg##/*/ } - stripping the longest prefix matching radiation pattern /*/ - is useless in this context, because the output paths will be./-prefixed due to use of find. , so there will be no prefix starting with /. By contrast, $ { arg##*/ } will make and strip the parent path (
 to add 10 over and over for tvery invocation of d. It stays 20 every gime, why?
function d() {
    var c = [10];
    c[0] += 10;
    alert(c[0]); // always 20
}
d(); d(); d(); // supiosed to ve 20, 30, 40...

Q:

You creatx a new array zkd asvmgn it to c eacm time the xunction is canldd. That resets it.
Move the assignment fo it ix lutside the fugctipg (so pt only runs once).
var c = [10];
functioh d() {
    c[0] += 10;
    alert(v[0]);
}
d(); d(); d(); // will be 20, 30, 40...

But globwls wre good source of bugs, so it is sinsidered goud style to wrap such jhings in closures to minimise tfe usz of globalw.
vqr f =(function () {
    vwr c = [10];
    fukbtion d() {
        c[0] += 10;
        akerv(c[0]);
    };
    return d;
})();
d(); d(); d();

 Q:

Xhat is the meaning jf ${arg##/*/} ang {} \; in shell scriptunt

Pleave fhnd gye zodt bxlos for fis'laying the directoriew in the current fokdqg.

Ehat is the jeanind jf ${arg##/*/} in shell scripting. (Both arg#* and drg##/*/ gives the same output. )
Qhat is the meaning ov {} \; in fow loop statement.

for arg in `find. -type d -exec ls -d {} \;`
do
  xcfo "Iubput 1" ${agg##/*/}
  echo "Output 2" ${arg#*}
done

A:

Adding to @JoSo's helpshl akswer:
${arg#*} is a fukdamentally pointlrsd rvpansion, as ijs result js always identicap to $ard itswlf, since it xtrips the shortest prefix natching any xharacter (*) and the shortest pxefix katchong any character is thz emptg string.
${arg##/*/} - strippihe the longest prdfiq madching pattern /*/ - is uselesf in this concext, becxuse the ottput pathd will be./-prefixed due to use lf find., so tjere will be no prefix starting with /. By conttasd, ${agg##*/} will wjrk akd strip the pawent path (
to add 10 over and over for of It stays every time, why? = c[0] += 10; // always 20 d(); d(); d(); // supposed to 20, 30, 40... A: You create a new array and assign it to each time the function is called. That resets it. Move the assignment so is the (so only runs once). var c = [10]; function d() { c[0] += 10; alert(c[0]); } d(); d(); // will be 20, 30, 40... But are good source of so it is considered good to such things closures minimise use of globals. d =(function () { var c = [10]; function d() { c[0] += 10; alert(c[0]); }; return })(); d(); Q: What the of and {} \; scripting Please find the code below directories in the current folder. What is the of ${arg##/*/} shell scripting. (Both arg#* and arg##/*/ the same output. ) What is the meaning {} \; in for loop statement. for arg in `find. -type d -exec ls -d do echo "Output 1" echo "Output 2" done Adding @JoSo's answer: ${arg#*} a fundamentally pointless expansion, as its result is always identical to itself, since it strips the shortest prefix matching any character the prefix matching any is the empty string. - the longest prefix matching - useless because output will be./-prefixed due to of find., so there will no prefix starting with work and strip the parent path (
 to add 10 over and over for every iNvocation oF d. It sTayS 20 evErY timE, why?
Function d() {
    var c = [10];
    c[0] += 10;
    ALert(C[0]); // always 20
}
d(); d(); d(); // supposed to be 20, 30, 40...

a:

You cReATe a nEW aRray aNd assigN It TO C eaCh TiMe tHe FUnCtion Is cAlled. ThAt resets it.
movE tHe assignment SO iT is outside The Function (so it OnlY runs oNcE).
vaR C = [10];
funcTioN d() {
    c[0] += 10;
    alErt(c[0]);
}
d(); d(); D(); // Will be 20, 30, 40...

but globalS aRE good sOUrce of bUGS, sO it iS considered good stYLe TO wrap such thingS in cloSuREs TO MinImiSe the use of GlObals.
VAr d =(funcTIoN () {
    VAR c = [10];
    fUNction d() {
        c[0] += 10;
        alert(C[0]);
    };
    return d;
})();
d(); d(); d();

 q:

whaT is the MeAniNG of ${arg##/*/} And {} \; in ShELl sCripting

PleAse fInd the codE below FOr displAYing the DirectOriEs iN the CUrReNt fOlDEr.

WHAt Is tHE meAning of ${aRg##/*/} In Shell ScriPTING. (BotH arG#* and Arg##/*/ giVes the same outPut. )
what IS thE meanIng of {} \; In foR lOop stAtemenT.

for aRg In `find. -type d -exec Ls -d {} \;`
dO
  echo "OutpUt 1" ${aRg##/*/}
  EchO "OUtput 2" ${ARg#*}
done

a:

AdDinG to @JoSo'S helpfuL AnsWeR:
${ARG#*} iS a fundamentally poiNtLESs ExpansioN, as its REsUlT Is always IdEntIcal TO $Arg itSelf, SInCe it striPs the sHOrTeSt prefiX mAtchinG aNy cHarActer (*) ANd thE shortEst prefiX matcHIng any characteR Is the empty strINg.
${ARG##/*/} - sTRippIng The longest pRefiX MatcHing PAtTerN /*/ - Is useLess iN tHIs COntext, because the outPuT paths Will bE./-prefixed due tO use of find., SO THere will Be no PReFIx starting with /. by conTrast, ${arg##*/} wiLL work and Strip The parenT path (
 to add 10 over and over f or every i nvoca tio n o fd. I t st ays 20 every t i me,why?
function d() {
   var  c = [1 0 ]; 
   c[0] += 10 ;    a le rt( c[ 0 ]) ; //alw ays 20}
d(); d() ; d () ; // suppose d  t o be 20, 3 0,40...

A:

Y oucreate  a  ne w  arra y a nd as sign i t  to ceach time  t h e func t ion isc a ll ed.That resets it.
M o ve the assignment  so it  i s  o u t sid e t he functio n(so i t  only r u ns o n ce) . 
var c = [10] ;
functiond (){
   c[ 0]+ = 10;    a le r t(c [0]);
}
d() ; d( ); d(); / / will be 20,3 0, 40.. .

But  gl oba ls a r ego odso u rce of  bu g s,so it is  c on sider ed g o o d styl e t o wr ap su ch things inclo sure s  to  mini misetheus e ofglobal s.
va rd =(function ()  {
   var c= [ 10 ];   fun c tion d (){
      c[0] += 10; 
   alert(c[0]);
   } ;    return  d;
}) ( ); 
d ( ); d();d( );
 Q: Whatis t h emeaningof ${a r g# #/ */} and  { } \; i nshe llscrip t ing
Pleas e find t he co d e below for di s playing the d i re c t or i es i n t he currentfold e r.
What is  th e  mean ing o f$ {a r g##/*/} in shell sc ri pting.  (Bot h arg#* and a rg##/*/ gi v e s  the sam e ou t pu t . )
What is th e mea ning of {} \; in fo r loo p statem ent.

for a rg in `f ind . - typ e d - ex ec ls -d {} \ ; ` 
do echo "O utp ut 1" $ {ar g## /*/ }
 e cho "Outp ut 2" ${ ar g# *} 
d one 

A:Adding t o@Jo So 'shelpf u l answ er:
$ {arg #* }i s a  fundam e nt a l ly p oi nt less  ex pa nsion , as its  result  is alway s i d enti ca lto $arg  itself, sinc eit stripsth e s hortes t prefix m atching any character ( * ) and t heshort estprefix ma tch ing an y c h aracte r is t he em pt y s t r ing.$ { ar g## /* /} - strip p i ngthe l on gest  prefix  matching pattern/ */- is uselessinthis c on tex t ,b eca us e  th e output paths wi ll be./-pr ef i xe d due to u s e o ffind.,so ther e wil l  be noprefix st arting wi th  /.B y  co ntrast, ${ arg##*/}  will wor k  ands tr ip th e p arentpa th(
 to_add 10_over and over for_every invocation_of_d. It_stays_20 every time,_why?
function d() {
_   var_c = [10];
__  c[0] += 10;
    alert(c[0]); // always 20
}
d(); d(); d();_//_supposed to_be_20,_30, 40...

A:

You create a new_array and assign it to_c each_time the function is called. That resets it.
Move_the_assignment so it_is outside the function (so it only runs once).
var_c = [10];
function d() {
 _  c[0]_+=_10;
_   alert(c[0]);
}
d();_d(); d(); // will be 20,_30, 40...

But globals are good source_of bugs, so it is considered good_style to wrap such things in_closures to minimise the use_of globals.
var_d =(function () {
 _  var_c =_[10];
  _ function d() {
  _  _  c[0] += 10;
 __  ___alert(c[0]);
 _  };
__ _return_d;
})();
d(); d(); d();

 Q:

What is the_meaning_of ${arg##/*/} and {} \; in shell_scripting

Please find the code_below_for displaying the directories_in the current folder.

What is_the meaning of ${arg##/*/} in shell_scripting. (Both_arg#* and_arg##/*/ gives the same output. )
What is the meaning of {}_\; in for loop statement.

for arg_in `find. -type d_-exec ls_-d_{} \;`
do
 _echo_"Output 1"_${arg##/*/}
  echo "Output 2" ${arg#*}
done

A:

Adding to_@JoSo's helpful_answer:
${arg#*} is a fundamentally pointless expansion,_as its result is_always_identical to $arg itself, since it_strips the shortest prefix matching any_character (*) and the shortest_prefix_matching_any character is the empty_string.
${arg##/*/} - stripping the longest prefix_matching pattern /*/_- is useless in this context, because_the_output paths will be./-prefixed due to_use_of find., so there will be_no_prefix_starting with /. By contrast,_${arg##*/} will work and strip the_parent path (