Liste des Groupes | Revenir à cl awk |
On 16.05.2024 15:11, Ed Morton wrote:I didn't notice the function keyword nestled in the preceding comments and didn't give it much thought, thanks for pointing that out.On 5/11/2024 11:57 PM, David Chmelik wrote:A function definition called once from the BEGIN section isn'tI'm learning more AWK basics and wrote function to read file, sort,>
print. I use GNU AWK (gawk) and its sort but printing is harder to get
working than anything... separate lines work, but when I use printf() or
set ORS then use print (for words one line) all awk outputs (on FreeBSD
UNIX 14 and Slackware GNU/Linux 15) is a space (and not even newline
before shell prompt)...
[...]------------------------------------------------------------------------>
# print_file_words.awk
# pass filename to function
BEGIN { print_file_words("data.txt"); }
>
# read two-column array from file and sort lines and print
function print_file_words(file) {
# set record separator then use print
# ORS=" "
Move the above to a BEGIN section so it is executed once total instead
of once per input line.
called "once per input line".
Les messages affichés proviennent d'usenet.