(for reference, the code is likely also here:https://github.com/garyexplains/exampleswhich is probably a better source than a video.)
Would there be any reason why this simple script on CentOS wouldn't run on Ubuntu?
[nsaunders@rolly awk]$ [nsaunders@rolly awk]$ awk -f loop.awk numbers.txt 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [nsaunders@rolly awk]$ [nsaunders@rolly awk]$ cat loop.awk func printlist(n) { for(i=1;i<=n;i++) { printf("%d ",i) } printf("\n")}{printlist($1)}[nsaunders@rolly awk]$ [nsaunders@rolly awk]$ cat numbers.txt 3712151631[nsaunders@rolly awk]$
I'm getting:
awk: loop.awk: line 11: function printlist never definedawk: loop.awk: line 11: function printlist never defined
awk version on Ubuntu:
mawk 1.3.4 20200120Copyright 2008-2019,2020, Thomas E. DickeyCopyright 1991-1996,2014, Michael D. Brennanrandom-funcs: srandom/randomregex-funcs: internalcompiled limits:sprintf buffer 8192maximum-integer 2147483647
And on the CentOS machine:
[nsaunders@rolly ~]$ [nsaunders@rolly ~]$ awk -W versionGNU Awk 4.2.1, API: 2.0 (GNU MPFR 3.1.6-p2, GNU MP 6.1.2)Copyright (C) 1989, 1991-2018 Free Software Foundation.This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 3 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see http://www.gnu.org/licenses/.[nsaunders@rolly ~]$
isn't awk
pretty much awk
regardless of what machine you're on?