piping input files into awk script 
Author Message
 piping input files into awk script

I'm trying to use the output of a ls listing commmand as a pipe into an
awk script.  I want the awk script to take each filename that the ls
command outputs as the input file for the execution of the script.

Any suggestions?



Sun, 17 Oct 2004 02:17:42 GMT  
 piping input files into awk script

Quote:

>I'm trying to use the output of a ls listing commmand as a pipe into an
>awk script.  I want the awk script to take each filename that the ls
>command outputs as the input file for the execution of the script.

>Any suggestions?

Read the filenames with 'getline' into ARGV[] array , explicity
specifying 'stdin' as the input file (else getline will advance
through the argument list after it closes)

ls |
  awk 'BEGIN{while(getline<"-")ARGV[ARGC++]=$0}
    {
    # main program here
    }
    '

seeya

--

                # if you are bored crack my sig.
1F8B0808CABB793C0000666667002D8E410E83300C04EF91F2877D00CA138A7A
EAA98F30C494480157B623C4EF1B508FDED1CEFA9152A23DE35D661593C5318E
630C313CD701BE92E390563326EE17A3CA818F5266E4C2461547F1F5267659CA
8EE2092F76C329ED02CA430C5373CC62FF94BAC6210B36D9F9BC4AB53378D978
80F2978A1A6E5D6F5133B67B6113178DC1059526698AFE5C17A5187E7D930492



Sun, 17 Oct 2004 02:34:56 GMT  
 piping input files into awk script
Quote:

> I'm trying to use the output of a ls listing commmand as a pipe into an
> awk script.  I want the awk script to take each filename that the ls
> command outputs as the input file for the execution of the script.

> Any suggestions?

ls | xargs awk 'her comes my script'

or awk 'here is the script' $(ls)

--
Vale !
                Christianus Auriocus



Sun, 17 Oct 2004 02:42:27 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Replacing a string from an input file within awk script

2. How to specify input file within awk script?

3. TCL Scripts: piping input / output

4. Creating an awk script to extract other scripts from a file

5. Keyboard Input during awk script

6. Redirect awk input in csh script

7. Multiple input files to awk

8. input from data file into awk under WindowsNT

9. can AWK read function from input file?

10. help on awk and ASCII file input

11. Q: Multi file input for AWK

12. Multiple input files in awk?

 

 
Powered by phpBB® Forum Software