July 27, 2021: As per IEEE Std 1003.1-2008, -F "str" is now consistent with -v FS="str" when str is null. Thanks to Warner Losh. July 24, 2021: Fix readrec's definition of a record. This fixes an issue with NetBSD's RS regular expression support that can cause an infinite read loop. Thanks to Miguel Pineiro Jr. Fix regular expression RS ^-anchoring. RS ^-anchoring needs to know if it is reading the first record of a file. This change restores a missing line that was overlooked when porting NetBSD's RS regex functionality. Thanks to Miguel Pineiro Jr. Fix size computation in replace_repeat() for special case REPEAT_WITH_Q. Thanks to Todd C. Miller. Also, included the tests from upstream, though they aren't yet connected to the tree. Sponsored by: Netflix
52 lines
869 B
Plaintext
52 lines
869 B
Plaintext
{ print }
|
|
{ print NR, NF, $0 }
|
|
{ $2 = length($2); print }
|
|
{ s += length($2) }
|
|
END { print s }
|
|
{ s += $3 }
|
|
END { print s }
|
|
{ for (i = NF; i > 0; i--)
|
|
printf "%s ", $i
|
|
printf("\n")
|
|
}
|
|
$1 == $1 && $2 == $2 # test some string compares
|
|
$1 != $2
|
|
{
|
|
sss = ""
|
|
for (i = NF; i > 0; i--)
|
|
sss = sss " " $i
|
|
print sss
|
|
}
|
|
{
|
|
xx[$1] += length
|
|
}
|
|
END {
|
|
for (i in xx)
|
|
print i, xx[i] | "sort"
|
|
}
|
|
NF % 2 == 0
|
|
length % 2 == 0
|
|
! /^./
|
|
/.$/
|
|
BEGIN { xxx = ".$" }
|
|
$0 ~ xxx
|
|
{ print substr($0, 10,10) }
|
|
{ $3 = "xxx" $3 "xxx"; $4--; print }
|
|
{ for (i = 1; i <= NF; i++)
|
|
x[i] = $i
|
|
for (i = 1; i <= NF; i++)
|
|
print x[i]
|
|
}
|
|
{ for (i = 1; i <= NF; i++)
|
|
y[i] = $i
|
|
for (i = 1; i <= NF; i++)
|
|
printf "%d %s\n", i, y[i]
|
|
}
|
|
function abs(x) { return (x < 0) ? -x : x }
|
|
BEGIN { n = 1000
|
|
for (i = 1; i < n; i++) x[i] = rand()
|
|
for (i in x)
|
|
for (j in x)
|
|
if (abs(x[i]-x[j]) < .01) break
|
|
}
|