I run a awk script. But, it is here. This is the command awk -f awk_scr ERR.txt
.
BEGIN {
FS=" "
target="missing"
}
{
for (i=1; i <= NR; i++) {
for(j=1; j <= NF; j++) {
if ($j == target) {
do {
printf $j > "final.txt"
} while (j == NF)
}
if (j == NF) {
printf "\n"
}
}
}
}
The ERR.txt
content is here. This awk script is for trimming what that is matched by "missing" and then print to a file, final.txt.
npm ERR! peer dep missing: react@^15.0.0, required by [email protected]
npm ERR! peer dep missing: [email protected] - 3, required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
npm ERR! missing: [email protected], required by [email protected]
But, when I execute the command, there is only a blank stdout.
================ADD MORE CONTENT================
This is what I expect to be, albeit I just spend few minutes to do. Anyway, the awk script is worth to use in the future.
missing: react@^15.0.0, required by [email protected]
missing: [email protected] - 3, required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
missing: [email protected], required by [email protected]
awk
script will be executed once for each line in the input. Having a loop overNR
is therefore not needed, unless you'd like to do the inner loop once for the first line, twice for the second line, thrice for the third, etc.LF
(\n
) to the file.do while
loop does not alterj
, so ifj == NF
, you're stuck. Did you check the file size of the final.txt file?final.txt
for the sample input?