This will print out all lines unit it reaches one with a capital R.
/R/ { exit }
{ print $0 }
$0 != prev { print; prev = $0 }
BEGIN {
ln = 0
}
{
ln++
if (ln % 2 == 0) next
print $0
}
(note that % (percent sign) means modulo, ln % 2 gives the rest of the division of ln by 2).
{
for(i = NF; i > 0; i--) { print $i }
}
if (match(str, /[A-Z][a-z]+[A-Z][A-Za-z]*/)) {
print substr(str, RSTART, RLENGTH)
}
/^[A-Z][A-Z]*$/ { print $0 }
/^$/ { next }
print $0 > "output.txt"
BEGIN { FS = "\t"; OFS = "\t"; fileIn = ""}
{
if (fileIn == "") {
fileIn = FILENAME
fileOut = fileIn " sa"
}
rnd = int(rand() * 1000)
if ( (rnd % 18 ) == 0 ) {
print $0 > fileOut
}
}
BEGIN {
FS = OFS = "\\"
fileIn = ""
}
{
if (fileIn == "") {
fileIn = FILENAME
fileOut = fileIn " (1000)"
}
nbI++
if (nbI <= 1000) {
print $0 > fileOut
} else { exit }
}
function readTable() {
while (erF = (getline < bgTable)) {
if (erF == -1) { print "Fichier '" bgTable "' introuvable!"; exit }
else {
bg = $1
frBgType[bg] = $2 + $4 + $6
frBgToken[bg] = $3 + $5 + $7
frBgPType[bg ".i"] = $2 + 0
frBgPToken[bg ".i"] = $3 + 0
frBgPType[bg ".m"] = $4 + 0
frBgPToken[bg ".m"] = $5 + 0
frBgPType[bg ".f"] = $6 + 0
frBgPToken[bg ".f"] = $7 + 0
}
}
}
BEGIN {
FS = "\\"; OFS = "\t"
test = 0
fileDOW = "DOW_mac"
}
{
while (getline < fileDOW) {
l++
if (test && l > 100) { close(fileDOW); exit }
ligne = ""
mis = ""
idNumb = $1
ligne = ligne $1 OFS $2 OFS $4 OFS $5 OFS $6 OFS $7 OFS $9
getline < "DPW_mac"
ligne = ligne OFS $5 OFS $6 OFS $7
if (idNumb != $1) { mis = "DPW " $1 " "}
getline < "DFW_mac"
ligne = ligne OFS $4 OFS $6 OFS $7
if (idNumb != $1) { mis = mis "DFW" $1 " "}
getline < "DMW_mac"
ligne = ligne OFS $5
if (idNumb != $1) { mis = mis "DMW" $1 " "}
print ligne > "Celex Dutch VG"
if (length(mis) > 2) {
print mis OFS ligne > "mismatch"
nbmis++
}
nbI++
if (nbI % 1000 == 0) { print nbI }
if (nbmis > 50) { exit }
}
}
Note to put spaces rather than zeros, consider using sprintf(”%10.0”, number)
BEGIN {
FS = "\t"; OFS = "\t"
fileIn = ""
zero [1] = "@0"
for (i = 2; i < 10; i++)
zero[i] = zero[i-1] "0"
}
{
if (fileIn == "") {
fileIn = FILENAME
fileOut = fileIn " @@"
}
toMark = $1
ligne = $0
id = zero [6 - length(toMark)] toMark
print id, ligne > fileOut
}