7 deleted 1 character in body
source | link

AcordingFirst, a disclaimer: Please don't parse the output of find. The code below is for illustration only, of how to incorporate command substitution into an Awk script in such a way that the commands can act upon pieces of Awk's input.

To Wildcardactually do a line count (wc -l) on each file found with find (which is the example use case), just use:

There is no scenario in which this code is the appropriate solution. Instead, doing it directly in find with -exec and -printf primaries will be simpler and more robust. See Why is looping over find's output bad practice? Example:

find . -type f -name '*txt' -exec sh -c 'for f do wc -l <"$f"; done' find-sh {} +
 find . -type f -name '*txt' -exec wc -l {} +

Acording to Wildcard :

There is no scenario in which this code is the appropriate solution. Instead, doing it directly in find with -exec and -printf primaries will be simpler and more robust. See Why is looping over find's output bad practice? Example:

find . -type f -name '*txt' -exec sh -c 'for f do wc -l <"$f"; done' find-sh {} +

First, a disclaimer: Please don't parse the output of find. The code below is for illustration only, of how to incorporate command substitution into an Awk script in such a way that the commands can act upon pieces of Awk's input.

To actually do a line count (wc -l) on each file found with find (which is the example use case), just use:

 find . -type f -name '*txt' -exec wc -l {} +

6 Added Wildcard comment.; Post Made Community Wiki
source | link

Acording to Wildcard :

There is no scenario in which this code is the appropriate solution. Instead, doing it directly in find with -exec and -printf primaries will be simpler and more robust. See Why is looping over find's output bad practice? Example:

find . -type f -name '*txt' -exec sh -c 'for f do wc -l <"$f"; done' find-sh {} +

However, to answer your questions as asked:

Acording to Wildcard :

There is no scenario in which this code is the appropriate solution. Instead, doing it directly in find with -exec and -printf primaries will be simpler and more robust. See Why is looping over find's output bad practice? Example:

find . -type f -name '*txt' -exec sh -c 'for f do wc -l <"$f"; done' find-sh {} +

However, to answer your questions as asked:

5 added 11 characters in body
source | link
find . | awk '/txt$/{"wc -l <"<\"" $NF " | cut"\"|cut -f1" | getline nl;(nl); print (nl )}'
find . | awk '/txt$/{
                       comm="wc -l <"<\"" $NF ""\" | cut -f1"
                       comm | getline nl;
                       close (comm);
                       print nl 
                    }'
find . | awk '/txt$/ && $NF!="." {  comm="wc -l <"<\"" $NF ""\" | cut -f1"
                                    comm | getline nl;
                                    close (comm);
                                    print nl 
                                 }'
find . | awk '/txt$/{"wc -l <" $NF " | cut -f1" | getline nl; print nl }'
find . | awk '/txt$/{
                       comm="wc -l <" $NF " | cut -f1"
                       comm | getline nl;
                       close (comm);
                       print nl 
                    }'
find . | awk '/txt$/ && $NF!="." {  comm="wc -l <" $NF " | cut -f1"
                                    comm | getline nl;
                                    close (comm);
                                    print nl 
                                 }'
find . | awk '/txt$/{"wc -l <\"" $NF "\"|cut -f1" | getline(nl); print(nl)}'
find . | awk '/txt$/{
                       comm="wc -l <\"" $NF "\" | cut -f1"
                       comm | getline nl;
                       close (comm);
                       print nl 
                    }'
find . | awk '/txt$/ && $NF!="." {  comm="wc -l <\"" $NF "\" | cut -f1"
                                    comm | getline nl;
                                    close (comm);
                                    print nl 
                                 }'
4 Added answer to Q2.
source | link
3 Added the correct close file command
source | link
2 Format.
source | link
1
source | link