Having nothing on stdout when executing awk script [closed]
Clash Royale CLAN TAG#URR8PPP
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 react-file-reader-input@1.1.4
npm ERR! peer dep missing: jquery@1.9.1 - 3, required by bootstrap@4.2.1
npm ERR! missing: mkdirp@0.5.1, required by node-pre-gyp@0.6.39
npm ERR! missing: rimraf@2.6.1, required by node-pre-gyp@0.6.39
npm ERR! missing: tar@2.2.1, required by node-pre-gyp@0.6.39
npm ERR! missing: hoek@2.16.3, required by hawk@3.1.3
npm ERR! missing: hoek@2.16.3, required by boom@2.10.1
npm ERR! missing: hoek@2.16.3, required by sntp@1.0.9
npm ERR! missing: minimist@0.0.8, required by mkdirp@0.5.1
npm ERR! missing: glob@7.1.2, required by rimraf@2.6.1
npm ERR! missing: fs.realpath@1.0.0, required by glob@7.1.2
npm ERR! missing: inflight@1.0.6, required by glob@7.1.2
npm ERR! missing: inherits@2.0.3, required by glob@7.1.2
npm ERR! missing: minimatch@3.0.4, required by glob@7.1.2
npm ERR! missing: once@1.4.0, required by glob@7.1.2
npm ERR! missing: path-is-absolute@1.0.1, required by glob@7.1.2
npm ERR! missing: once@1.4.0, required by inflight@1.0.6
npm ERR! missing: wrappy@1.0.2, required by inflight@1.0.6
npm ERR! missing: brace-expansion@1.1.7, required by minimatch@3.0.4
npm ERR! missing: balanced-match@0.4.2, required by brace-expansion@1.1.7
npm ERR! missing: concat-map@0.0.1, required by brace-expansion@1.1.7
npm ERR! missing: block-stream@0.0.9, required by tar@2.2.1
npm ERR! missing: fstream@1.0.11, required by tar@2.2.1
npm ERR! missing: inherits@2.0.3, required by tar@2.2.1
npm ERR! missing: inherits@2.0.3, required by block-stream@0.0.9
npm ERR! missing: graceful-fs@4.1.11, required by fstream@1.0.11
npm ERR! missing: inherits@2.0.3, required by fstream@1.0.11
npm ERR! missing: mkdirp@0.5.1, required by fstream@1.0.11
npm ERR! missing: rimraf@2.6.1, required by fstream@1.0.11
npm ERR! missing: fstream@1.0.11, required by tar-pack@3.4.0
npm ERR! missing: once@1.4.0, required by tar-pack@3.4.0
npm ERR! missing: rimraf@2.6.1, required by tar-pack@3.4.0
npm ERR! missing: tar@2.2.1, required by tar-pack@3.4.0
npm ERR! missing: fstream@1.0.11, required by fstream-ignore@1.0.5
npm ERR! missing: inherits@2.0.3, required by fstream-ignore@1.0.5
npm ERR! missing: minimatch@3.0.4, required by fstream-ignore@1.0.5
npm ERR! missing: wrappy@1.0.2, required by once@1.4.0
npm ERR! missing: inherits@2.0.3, required by readable-stream@2.2.9
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 react-file-reader-input@1.1.4
missing: jquery@1.9.1 - 3, required by bootstrap@4.2.1
missing: mkdirp@0.5.1, required by node-pre-gyp@0.6.39
missing: rimraf@2.6.1, required by node-pre-gyp@0.6.39
missing: tar@2.2.1, required by node-pre-gyp@0.6.39
missing: hoek@2.16.3, required by hawk@3.1.3
missing: hoek@2.16.3, required by boom@2.10.1
missing: hoek@2.16.3, required by sntp@1.0.9
missing: minimist@0.0.8, required by mkdirp@0.5.1
missing: glob@7.1.2, required by rimraf@2.6.1
missing: fs.realpath@1.0.0, required by glob@7.1.2
missing: inflight@1.0.6, required by glob@7.1.2
missing: inherits@2.0.3, required by glob@7.1.2
missing: minimatch@3.0.4, required by glob@7.1.2
missing: once@1.4.0, required by glob@7.1.2
missing: path-is-absolute@1.0.1, required by glob@7.1.2
missing: once@1.4.0, required by inflight@1.0.6
missing: wrappy@1.0.2, required by inflight@1.0.6
missing: brace-expansion@1.1.7, required by minimatch@3.0.4
missing: balanced-match@0.4.2, required by brace-expansion@1.1.7
missing: concat-map@0.0.1, required by brace-expansion@1.1.7
missing: block-stream@0.0.9, required by tar@2.2.1
missing: fstream@1.0.11, required by tar@2.2.1
missing: inherits@2.0.3, required by tar@2.2.1
missing: inherits@2.0.3, required by block-stream@0.0.9
missing: graceful-fs@4.1.11, required by fstream@1.0.11
missing: inherits@2.0.3, required by fstream@1.0.11
missing: mkdirp@0.5.1, required by fstream@1.0.11
missing: rimraf@2.6.1, required by fstream@1.0.11
missing: fstream@1.0.11, required by tar-pack@3.4.0
missing: once@1.4.0, required by tar-pack@3.4.0
missing: rimraf@2.6.1, required by tar-pack@3.4.0
missing: tar@2.2.1, required by tar-pack@3.4.0
missing: fstream@1.0.11, required by fstream-ignore@1.0.5
missing: inherits@2.0.3, required by fstream-ignore@1.0.5
missing: minimatch@3.0.4, required by fstream-ignore@1.0.5
missing: wrappy@1.0.2, required by once@1.4.0
missing: inherits@2.0.3, required by readable-stream@2.2.9
shell-script awk
closed as unclear what you're asking by Kusalananda, Mr Shunz, Jeff Schaller, Christopher, αғsнιη Jan 16 at 3:23
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
|
show 2 more comments
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 react-file-reader-input@1.1.4
npm ERR! peer dep missing: jquery@1.9.1 - 3, required by bootstrap@4.2.1
npm ERR! missing: mkdirp@0.5.1, required by node-pre-gyp@0.6.39
npm ERR! missing: rimraf@2.6.1, required by node-pre-gyp@0.6.39
npm ERR! missing: tar@2.2.1, required by node-pre-gyp@0.6.39
npm ERR! missing: hoek@2.16.3, required by hawk@3.1.3
npm ERR! missing: hoek@2.16.3, required by boom@2.10.1
npm ERR! missing: hoek@2.16.3, required by sntp@1.0.9
npm ERR! missing: minimist@0.0.8, required by mkdirp@0.5.1
npm ERR! missing: glob@7.1.2, required by rimraf@2.6.1
npm ERR! missing: fs.realpath@1.0.0, required by glob@7.1.2
npm ERR! missing: inflight@1.0.6, required by glob@7.1.2
npm ERR! missing: inherits@2.0.3, required by glob@7.1.2
npm ERR! missing: minimatch@3.0.4, required by glob@7.1.2
npm ERR! missing: once@1.4.0, required by glob@7.1.2
npm ERR! missing: path-is-absolute@1.0.1, required by glob@7.1.2
npm ERR! missing: once@1.4.0, required by inflight@1.0.6
npm ERR! missing: wrappy@1.0.2, required by inflight@1.0.6
npm ERR! missing: brace-expansion@1.1.7, required by minimatch@3.0.4
npm ERR! missing: balanced-match@0.4.2, required by brace-expansion@1.1.7
npm ERR! missing: concat-map@0.0.1, required by brace-expansion@1.1.7
npm ERR! missing: block-stream@0.0.9, required by tar@2.2.1
npm ERR! missing: fstream@1.0.11, required by tar@2.2.1
npm ERR! missing: inherits@2.0.3, required by tar@2.2.1
npm ERR! missing: inherits@2.0.3, required by block-stream@0.0.9
npm ERR! missing: graceful-fs@4.1.11, required by fstream@1.0.11
npm ERR! missing: inherits@2.0.3, required by fstream@1.0.11
npm ERR! missing: mkdirp@0.5.1, required by fstream@1.0.11
npm ERR! missing: rimraf@2.6.1, required by fstream@1.0.11
npm ERR! missing: fstream@1.0.11, required by tar-pack@3.4.0
npm ERR! missing: once@1.4.0, required by tar-pack@3.4.0
npm ERR! missing: rimraf@2.6.1, required by tar-pack@3.4.0
npm ERR! missing: tar@2.2.1, required by tar-pack@3.4.0
npm ERR! missing: fstream@1.0.11, required by fstream-ignore@1.0.5
npm ERR! missing: inherits@2.0.3, required by fstream-ignore@1.0.5
npm ERR! missing: minimatch@3.0.4, required by fstream-ignore@1.0.5
npm ERR! missing: wrappy@1.0.2, required by once@1.4.0
npm ERR! missing: inherits@2.0.3, required by readable-stream@2.2.9
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 react-file-reader-input@1.1.4
missing: jquery@1.9.1 - 3, required by bootstrap@4.2.1
missing: mkdirp@0.5.1, required by node-pre-gyp@0.6.39
missing: rimraf@2.6.1, required by node-pre-gyp@0.6.39
missing: tar@2.2.1, required by node-pre-gyp@0.6.39
missing: hoek@2.16.3, required by hawk@3.1.3
missing: hoek@2.16.3, required by boom@2.10.1
missing: hoek@2.16.3, required by sntp@1.0.9
missing: minimist@0.0.8, required by mkdirp@0.5.1
missing: glob@7.1.2, required by rimraf@2.6.1
missing: fs.realpath@1.0.0, required by glob@7.1.2
missing: inflight@1.0.6, required by glob@7.1.2
missing: inherits@2.0.3, required by glob@7.1.2
missing: minimatch@3.0.4, required by glob@7.1.2
missing: once@1.4.0, required by glob@7.1.2
missing: path-is-absolute@1.0.1, required by glob@7.1.2
missing: once@1.4.0, required by inflight@1.0.6
missing: wrappy@1.0.2, required by inflight@1.0.6
missing: brace-expansion@1.1.7, required by minimatch@3.0.4
missing: balanced-match@0.4.2, required by brace-expansion@1.1.7
missing: concat-map@0.0.1, required by brace-expansion@1.1.7
missing: block-stream@0.0.9, required by tar@2.2.1
missing: fstream@1.0.11, required by tar@2.2.1
missing: inherits@2.0.3, required by tar@2.2.1
missing: inherits@2.0.3, required by block-stream@0.0.9
missing: graceful-fs@4.1.11, required by fstream@1.0.11
missing: inherits@2.0.3, required by fstream@1.0.11
missing: mkdirp@0.5.1, required by fstream@1.0.11
missing: rimraf@2.6.1, required by fstream@1.0.11
missing: fstream@1.0.11, required by tar-pack@3.4.0
missing: once@1.4.0, required by tar-pack@3.4.0
missing: rimraf@2.6.1, required by tar-pack@3.4.0
missing: tar@2.2.1, required by tar-pack@3.4.0
missing: fstream@1.0.11, required by fstream-ignore@1.0.5
missing: inherits@2.0.3, required by fstream-ignore@1.0.5
missing: minimatch@3.0.4, required by fstream-ignore@1.0.5
missing: wrappy@1.0.2, required by once@1.4.0
missing: inherits@2.0.3, required by readable-stream@2.2.9
shell-script awk
closed as unclear what you're asking by Kusalananda, Mr Shunz, Jeff Schaller, Christopher, αғsнιη Jan 16 at 3:23
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
3
Please clarify what you mean by "trimming". Note that the code block that you have in yourawk
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.
– Kusalananda
Jan 15 at 6:44
You do not redirect yourLF
(n
) to the file.
– kvantour
Jan 15 at 8:25
1
Please edit the question and add the expected output, otherwise we can just guess what you want to achieve as your awk script is not clear.
– RoVo
Jan 15 at 9:53
2
You probably see nothing because you get stuck in an infinite loop: thedo while
loop does not alterj
, so ifj == NF
, you're stuck. Did you check the file size of the final.txt file?
– glenn jackman
Jan 15 at 19:26
What's infinal.txt
for the sample input?
– roaima
Jan 15 at 22:48
|
show 2 more comments
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 react-file-reader-input@1.1.4
npm ERR! peer dep missing: jquery@1.9.1 - 3, required by bootstrap@4.2.1
npm ERR! missing: mkdirp@0.5.1, required by node-pre-gyp@0.6.39
npm ERR! missing: rimraf@2.6.1, required by node-pre-gyp@0.6.39
npm ERR! missing: tar@2.2.1, required by node-pre-gyp@0.6.39
npm ERR! missing: hoek@2.16.3, required by hawk@3.1.3
npm ERR! missing: hoek@2.16.3, required by boom@2.10.1
npm ERR! missing: hoek@2.16.3, required by sntp@1.0.9
npm ERR! missing: minimist@0.0.8, required by mkdirp@0.5.1
npm ERR! missing: glob@7.1.2, required by rimraf@2.6.1
npm ERR! missing: fs.realpath@1.0.0, required by glob@7.1.2
npm ERR! missing: inflight@1.0.6, required by glob@7.1.2
npm ERR! missing: inherits@2.0.3, required by glob@7.1.2
npm ERR! missing: minimatch@3.0.4, required by glob@7.1.2
npm ERR! missing: once@1.4.0, required by glob@7.1.2
npm ERR! missing: path-is-absolute@1.0.1, required by glob@7.1.2
npm ERR! missing: once@1.4.0, required by inflight@1.0.6
npm ERR! missing: wrappy@1.0.2, required by inflight@1.0.6
npm ERR! missing: brace-expansion@1.1.7, required by minimatch@3.0.4
npm ERR! missing: balanced-match@0.4.2, required by brace-expansion@1.1.7
npm ERR! missing: concat-map@0.0.1, required by brace-expansion@1.1.7
npm ERR! missing: block-stream@0.0.9, required by tar@2.2.1
npm ERR! missing: fstream@1.0.11, required by tar@2.2.1
npm ERR! missing: inherits@2.0.3, required by tar@2.2.1
npm ERR! missing: inherits@2.0.3, required by block-stream@0.0.9
npm ERR! missing: graceful-fs@4.1.11, required by fstream@1.0.11
npm ERR! missing: inherits@2.0.3, required by fstream@1.0.11
npm ERR! missing: mkdirp@0.5.1, required by fstream@1.0.11
npm ERR! missing: rimraf@2.6.1, required by fstream@1.0.11
npm ERR! missing: fstream@1.0.11, required by tar-pack@3.4.0
npm ERR! missing: once@1.4.0, required by tar-pack@3.4.0
npm ERR! missing: rimraf@2.6.1, required by tar-pack@3.4.0
npm ERR! missing: tar@2.2.1, required by tar-pack@3.4.0
npm ERR! missing: fstream@1.0.11, required by fstream-ignore@1.0.5
npm ERR! missing: inherits@2.0.3, required by fstream-ignore@1.0.5
npm ERR! missing: minimatch@3.0.4, required by fstream-ignore@1.0.5
npm ERR! missing: wrappy@1.0.2, required by once@1.4.0
npm ERR! missing: inherits@2.0.3, required by readable-stream@2.2.9
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 react-file-reader-input@1.1.4
missing: jquery@1.9.1 - 3, required by bootstrap@4.2.1
missing: mkdirp@0.5.1, required by node-pre-gyp@0.6.39
missing: rimraf@2.6.1, required by node-pre-gyp@0.6.39
missing: tar@2.2.1, required by node-pre-gyp@0.6.39
missing: hoek@2.16.3, required by hawk@3.1.3
missing: hoek@2.16.3, required by boom@2.10.1
missing: hoek@2.16.3, required by sntp@1.0.9
missing: minimist@0.0.8, required by mkdirp@0.5.1
missing: glob@7.1.2, required by rimraf@2.6.1
missing: fs.realpath@1.0.0, required by glob@7.1.2
missing: inflight@1.0.6, required by glob@7.1.2
missing: inherits@2.0.3, required by glob@7.1.2
missing: minimatch@3.0.4, required by glob@7.1.2
missing: once@1.4.0, required by glob@7.1.2
missing: path-is-absolute@1.0.1, required by glob@7.1.2
missing: once@1.4.0, required by inflight@1.0.6
missing: wrappy@1.0.2, required by inflight@1.0.6
missing: brace-expansion@1.1.7, required by minimatch@3.0.4
missing: balanced-match@0.4.2, required by brace-expansion@1.1.7
missing: concat-map@0.0.1, required by brace-expansion@1.1.7
missing: block-stream@0.0.9, required by tar@2.2.1
missing: fstream@1.0.11, required by tar@2.2.1
missing: inherits@2.0.3, required by tar@2.2.1
missing: inherits@2.0.3, required by block-stream@0.0.9
missing: graceful-fs@4.1.11, required by fstream@1.0.11
missing: inherits@2.0.3, required by fstream@1.0.11
missing: mkdirp@0.5.1, required by fstream@1.0.11
missing: rimraf@2.6.1, required by fstream@1.0.11
missing: fstream@1.0.11, required by tar-pack@3.4.0
missing: once@1.4.0, required by tar-pack@3.4.0
missing: rimraf@2.6.1, required by tar-pack@3.4.0
missing: tar@2.2.1, required by tar-pack@3.4.0
missing: fstream@1.0.11, required by fstream-ignore@1.0.5
missing: inherits@2.0.3, required by fstream-ignore@1.0.5
missing: minimatch@3.0.4, required by fstream-ignore@1.0.5
missing: wrappy@1.0.2, required by once@1.4.0
missing: inherits@2.0.3, required by readable-stream@2.2.9
shell-script awk
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 react-file-reader-input@1.1.4
npm ERR! peer dep missing: jquery@1.9.1 - 3, required by bootstrap@4.2.1
npm ERR! missing: mkdirp@0.5.1, required by node-pre-gyp@0.6.39
npm ERR! missing: rimraf@2.6.1, required by node-pre-gyp@0.6.39
npm ERR! missing: tar@2.2.1, required by node-pre-gyp@0.6.39
npm ERR! missing: hoek@2.16.3, required by hawk@3.1.3
npm ERR! missing: hoek@2.16.3, required by boom@2.10.1
npm ERR! missing: hoek@2.16.3, required by sntp@1.0.9
npm ERR! missing: minimist@0.0.8, required by mkdirp@0.5.1
npm ERR! missing: glob@7.1.2, required by rimraf@2.6.1
npm ERR! missing: fs.realpath@1.0.0, required by glob@7.1.2
npm ERR! missing: inflight@1.0.6, required by glob@7.1.2
npm ERR! missing: inherits@2.0.3, required by glob@7.1.2
npm ERR! missing: minimatch@3.0.4, required by glob@7.1.2
npm ERR! missing: once@1.4.0, required by glob@7.1.2
npm ERR! missing: path-is-absolute@1.0.1, required by glob@7.1.2
npm ERR! missing: once@1.4.0, required by inflight@1.0.6
npm ERR! missing: wrappy@1.0.2, required by inflight@1.0.6
npm ERR! missing: brace-expansion@1.1.7, required by minimatch@3.0.4
npm ERR! missing: balanced-match@0.4.2, required by brace-expansion@1.1.7
npm ERR! missing: concat-map@0.0.1, required by brace-expansion@1.1.7
npm ERR! missing: block-stream@0.0.9, required by tar@2.2.1
npm ERR! missing: fstream@1.0.11, required by tar@2.2.1
npm ERR! missing: inherits@2.0.3, required by tar@2.2.1
npm ERR! missing: inherits@2.0.3, required by block-stream@0.0.9
npm ERR! missing: graceful-fs@4.1.11, required by fstream@1.0.11
npm ERR! missing: inherits@2.0.3, required by fstream@1.0.11
npm ERR! missing: mkdirp@0.5.1, required by fstream@1.0.11
npm ERR! missing: rimraf@2.6.1, required by fstream@1.0.11
npm ERR! missing: fstream@1.0.11, required by tar-pack@3.4.0
npm ERR! missing: once@1.4.0, required by tar-pack@3.4.0
npm ERR! missing: rimraf@2.6.1, required by tar-pack@3.4.0
npm ERR! missing: tar@2.2.1, required by tar-pack@3.4.0
npm ERR! missing: fstream@1.0.11, required by fstream-ignore@1.0.5
npm ERR! missing: inherits@2.0.3, required by fstream-ignore@1.0.5
npm ERR! missing: minimatch@3.0.4, required by fstream-ignore@1.0.5
npm ERR! missing: wrappy@1.0.2, required by once@1.4.0
npm ERR! missing: inherits@2.0.3, required by readable-stream@2.2.9
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 react-file-reader-input@1.1.4
missing: jquery@1.9.1 - 3, required by bootstrap@4.2.1
missing: mkdirp@0.5.1, required by node-pre-gyp@0.6.39
missing: rimraf@2.6.1, required by node-pre-gyp@0.6.39
missing: tar@2.2.1, required by node-pre-gyp@0.6.39
missing: hoek@2.16.3, required by hawk@3.1.3
missing: hoek@2.16.3, required by boom@2.10.1
missing: hoek@2.16.3, required by sntp@1.0.9
missing: minimist@0.0.8, required by mkdirp@0.5.1
missing: glob@7.1.2, required by rimraf@2.6.1
missing: fs.realpath@1.0.0, required by glob@7.1.2
missing: inflight@1.0.6, required by glob@7.1.2
missing: inherits@2.0.3, required by glob@7.1.2
missing: minimatch@3.0.4, required by glob@7.1.2
missing: once@1.4.0, required by glob@7.1.2
missing: path-is-absolute@1.0.1, required by glob@7.1.2
missing: once@1.4.0, required by inflight@1.0.6
missing: wrappy@1.0.2, required by inflight@1.0.6
missing: brace-expansion@1.1.7, required by minimatch@3.0.4
missing: balanced-match@0.4.2, required by brace-expansion@1.1.7
missing: concat-map@0.0.1, required by brace-expansion@1.1.7
missing: block-stream@0.0.9, required by tar@2.2.1
missing: fstream@1.0.11, required by tar@2.2.1
missing: inherits@2.0.3, required by tar@2.2.1
missing: inherits@2.0.3, required by block-stream@0.0.9
missing: graceful-fs@4.1.11, required by fstream@1.0.11
missing: inherits@2.0.3, required by fstream@1.0.11
missing: mkdirp@0.5.1, required by fstream@1.0.11
missing: rimraf@2.6.1, required by fstream@1.0.11
missing: fstream@1.0.11, required by tar-pack@3.4.0
missing: once@1.4.0, required by tar-pack@3.4.0
missing: rimraf@2.6.1, required by tar-pack@3.4.0
missing: tar@2.2.1, required by tar-pack@3.4.0
missing: fstream@1.0.11, required by fstream-ignore@1.0.5
missing: inherits@2.0.3, required by fstream-ignore@1.0.5
missing: minimatch@3.0.4, required by fstream-ignore@1.0.5
missing: wrappy@1.0.2, required by once@1.4.0
missing: inherits@2.0.3, required by readable-stream@2.2.9
shell-script awk
shell-script awk
edited Jan 16 at 1:41
jefferyear
asked Jan 15 at 6:39
jefferyearjefferyear
5519
5519
closed as unclear what you're asking by Kusalananda, Mr Shunz, Jeff Schaller, Christopher, αғsнιη Jan 16 at 3:23
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Kusalananda, Mr Shunz, Jeff Schaller, Christopher, αғsнιη Jan 16 at 3:23
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
3
Please clarify what you mean by "trimming". Note that the code block that you have in yourawk
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.
– Kusalananda
Jan 15 at 6:44
You do not redirect yourLF
(n
) to the file.
– kvantour
Jan 15 at 8:25
1
Please edit the question and add the expected output, otherwise we can just guess what you want to achieve as your awk script is not clear.
– RoVo
Jan 15 at 9:53
2
You probably see nothing because you get stuck in an infinite loop: thedo while
loop does not alterj
, so ifj == NF
, you're stuck. Did you check the file size of the final.txt file?
– glenn jackman
Jan 15 at 19:26
What's infinal.txt
for the sample input?
– roaima
Jan 15 at 22:48
|
show 2 more comments
3
Please clarify what you mean by "trimming". Note that the code block that you have in yourawk
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.
– Kusalananda
Jan 15 at 6:44
You do not redirect yourLF
(n
) to the file.
– kvantour
Jan 15 at 8:25
1
Please edit the question and add the expected output, otherwise we can just guess what you want to achieve as your awk script is not clear.
– RoVo
Jan 15 at 9:53
2
You probably see nothing because you get stuck in an infinite loop: thedo while
loop does not alterj
, so ifj == NF
, you're stuck. Did you check the file size of the final.txt file?
– glenn jackman
Jan 15 at 19:26
What's infinal.txt
for the sample input?
– roaima
Jan 15 at 22:48
3
3
Please clarify what you mean by "trimming". Note that the code block that you have in your
awk
script will be executed once for each line in the input. Having a loop over NR
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.– Kusalananda
Jan 15 at 6:44
Please clarify what you mean by "trimming". Note that the code block that you have in your
awk
script will be executed once for each line in the input. Having a loop over NR
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.– Kusalananda
Jan 15 at 6:44
You do not redirect your
LF
(n
) to the file.– kvantour
Jan 15 at 8:25
You do not redirect your
LF
(n
) to the file.– kvantour
Jan 15 at 8:25
1
1
Please edit the question and add the expected output, otherwise we can just guess what you want to achieve as your awk script is not clear.
– RoVo
Jan 15 at 9:53
Please edit the question and add the expected output, otherwise we can just guess what you want to achieve as your awk script is not clear.
– RoVo
Jan 15 at 9:53
2
2
You probably see nothing because you get stuck in an infinite loop: the
do while
loop does not alter j
, so if j == NF
, you're stuck. Did you check the file size of the final.txt file?– glenn jackman
Jan 15 at 19:26
You probably see nothing because you get stuck in an infinite loop: the
do while
loop does not alter j
, so if j == NF
, you're stuck. Did you check the file size of the final.txt file?– glenn jackman
Jan 15 at 19:26
What's in
final.txt
for the sample input?– roaima
Jan 15 at 22:48
What's in
final.txt
for the sample input?– roaima
Jan 15 at 22:48
|
show 2 more comments
2 Answers
2
active
oldest
votes
# awk_scr
BEGIN
# clear the output file if it already exists
# you can do this using your shell instead
ORS = ""
print "" > "final.txt"
ORS = "n"
/missing/
# delete all characters prior to the last occurrence of "missing:"
# this assumes that there is only one sub-string "missing:" per line
sub(/.*missing:/, "missing:", $0)
# append the updated line to the output file
print $0 >> "final.txt"
Then run awk -f awk_scr ERR.txt && cat final.txt
.
Another solution is to use sed
, which is shorter:
sed 's/^.*missing:/missing:/' ERR.txt | tee final.txt
However, it has the same downside as the awk solution: it assumes that there is only one occurrence of "missing:" per line. This is due to the fact that both awk
and sed
only match greedily.
To simulate lazy matching, you can do the following, instead (which is better):
sed -E 's/(missing)(.*)|./12/g' ERR.txt | tee final.txt
add a comment |
I believe your script is a bit convoluted and shows a misunderstanding of what 'awk' is all about. Awk programs consist out of a list of
pattern actions
statement. Every time a new record/line is read, awk will process that line by executing the pattern-action statement one by one. From what I see, it looks like you imagine that awk reads the full file in memory and you can then process it using a for loop over the number of records. This is not how it works.
The following awk will probably do what you request:
awk '/missing/' inputfile > "missing.txt"
Here, the patter is /missing/
and the action is the default action 1
which is equal to print $0
, or print the full record. The pattern /missing/
states, select all lines which contain the substring "missing"
1
Or justgrep -F 'missing:' <inputfile >missing.txt
.
– Kusalananda
Jan 15 at 9:46
1
I suspectawk '/missing/ print $NF' inputfile > "missing.txt"
is what is wanted.
– glenn jackman
Jan 15 at 19:28
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
# awk_scr
BEGIN
# clear the output file if it already exists
# you can do this using your shell instead
ORS = ""
print "" > "final.txt"
ORS = "n"
/missing/
# delete all characters prior to the last occurrence of "missing:"
# this assumes that there is only one sub-string "missing:" per line
sub(/.*missing:/, "missing:", $0)
# append the updated line to the output file
print $0 >> "final.txt"
Then run awk -f awk_scr ERR.txt && cat final.txt
.
Another solution is to use sed
, which is shorter:
sed 's/^.*missing:/missing:/' ERR.txt | tee final.txt
However, it has the same downside as the awk solution: it assumes that there is only one occurrence of "missing:" per line. This is due to the fact that both awk
and sed
only match greedily.
To simulate lazy matching, you can do the following, instead (which is better):
sed -E 's/(missing)(.*)|./12/g' ERR.txt | tee final.txt
add a comment |
# awk_scr
BEGIN
# clear the output file if it already exists
# you can do this using your shell instead
ORS = ""
print "" > "final.txt"
ORS = "n"
/missing/
# delete all characters prior to the last occurrence of "missing:"
# this assumes that there is only one sub-string "missing:" per line
sub(/.*missing:/, "missing:", $0)
# append the updated line to the output file
print $0 >> "final.txt"
Then run awk -f awk_scr ERR.txt && cat final.txt
.
Another solution is to use sed
, which is shorter:
sed 's/^.*missing:/missing:/' ERR.txt | tee final.txt
However, it has the same downside as the awk solution: it assumes that there is only one occurrence of "missing:" per line. This is due to the fact that both awk
and sed
only match greedily.
To simulate lazy matching, you can do the following, instead (which is better):
sed -E 's/(missing)(.*)|./12/g' ERR.txt | tee final.txt
add a comment |
# awk_scr
BEGIN
# clear the output file if it already exists
# you can do this using your shell instead
ORS = ""
print "" > "final.txt"
ORS = "n"
/missing/
# delete all characters prior to the last occurrence of "missing:"
# this assumes that there is only one sub-string "missing:" per line
sub(/.*missing:/, "missing:", $0)
# append the updated line to the output file
print $0 >> "final.txt"
Then run awk -f awk_scr ERR.txt && cat final.txt
.
Another solution is to use sed
, which is shorter:
sed 's/^.*missing:/missing:/' ERR.txt | tee final.txt
However, it has the same downside as the awk solution: it assumes that there is only one occurrence of "missing:" per line. This is due to the fact that both awk
and sed
only match greedily.
To simulate lazy matching, you can do the following, instead (which is better):
sed -E 's/(missing)(.*)|./12/g' ERR.txt | tee final.txt
# awk_scr
BEGIN
# clear the output file if it already exists
# you can do this using your shell instead
ORS = ""
print "" > "final.txt"
ORS = "n"
/missing/
# delete all characters prior to the last occurrence of "missing:"
# this assumes that there is only one sub-string "missing:" per line
sub(/.*missing:/, "missing:", $0)
# append the updated line to the output file
print $0 >> "final.txt"
Then run awk -f awk_scr ERR.txt && cat final.txt
.
Another solution is to use sed
, which is shorter:
sed 's/^.*missing:/missing:/' ERR.txt | tee final.txt
However, it has the same downside as the awk solution: it assumes that there is only one occurrence of "missing:" per line. This is due to the fact that both awk
and sed
only match greedily.
To simulate lazy matching, you can do the following, instead (which is better):
sed -E 's/(missing)(.*)|./12/g' ERR.txt | tee final.txt
edited Jan 16 at 4:31
answered Jan 16 at 2:59
Niko GambtNiko Gambt
1836
1836
add a comment |
add a comment |
I believe your script is a bit convoluted and shows a misunderstanding of what 'awk' is all about. Awk programs consist out of a list of
pattern actions
statement. Every time a new record/line is read, awk will process that line by executing the pattern-action statement one by one. From what I see, it looks like you imagine that awk reads the full file in memory and you can then process it using a for loop over the number of records. This is not how it works.
The following awk will probably do what you request:
awk '/missing/' inputfile > "missing.txt"
Here, the patter is /missing/
and the action is the default action 1
which is equal to print $0
, or print the full record. The pattern /missing/
states, select all lines which contain the substring "missing"
1
Or justgrep -F 'missing:' <inputfile >missing.txt
.
– Kusalananda
Jan 15 at 9:46
1
I suspectawk '/missing/ print $NF' inputfile > "missing.txt"
is what is wanted.
– glenn jackman
Jan 15 at 19:28
add a comment |
I believe your script is a bit convoluted and shows a misunderstanding of what 'awk' is all about. Awk programs consist out of a list of
pattern actions
statement. Every time a new record/line is read, awk will process that line by executing the pattern-action statement one by one. From what I see, it looks like you imagine that awk reads the full file in memory and you can then process it using a for loop over the number of records. This is not how it works.
The following awk will probably do what you request:
awk '/missing/' inputfile > "missing.txt"
Here, the patter is /missing/
and the action is the default action 1
which is equal to print $0
, or print the full record. The pattern /missing/
states, select all lines which contain the substring "missing"
1
Or justgrep -F 'missing:' <inputfile >missing.txt
.
– Kusalananda
Jan 15 at 9:46
1
I suspectawk '/missing/ print $NF' inputfile > "missing.txt"
is what is wanted.
– glenn jackman
Jan 15 at 19:28
add a comment |
I believe your script is a bit convoluted and shows a misunderstanding of what 'awk' is all about. Awk programs consist out of a list of
pattern actions
statement. Every time a new record/line is read, awk will process that line by executing the pattern-action statement one by one. From what I see, it looks like you imagine that awk reads the full file in memory and you can then process it using a for loop over the number of records. This is not how it works.
The following awk will probably do what you request:
awk '/missing/' inputfile > "missing.txt"
Here, the patter is /missing/
and the action is the default action 1
which is equal to print $0
, or print the full record. The pattern /missing/
states, select all lines which contain the substring "missing"
I believe your script is a bit convoluted and shows a misunderstanding of what 'awk' is all about. Awk programs consist out of a list of
pattern actions
statement. Every time a new record/line is read, awk will process that line by executing the pattern-action statement one by one. From what I see, it looks like you imagine that awk reads the full file in memory and you can then process it using a for loop over the number of records. This is not how it works.
The following awk will probably do what you request:
awk '/missing/' inputfile > "missing.txt"
Here, the patter is /missing/
and the action is the default action 1
which is equal to print $0
, or print the full record. The pattern /missing/
states, select all lines which contain the substring "missing"
answered Jan 15 at 8:32
kvantourkvantour
1112
1112
1
Or justgrep -F 'missing:' <inputfile >missing.txt
.
– Kusalananda
Jan 15 at 9:46
1
I suspectawk '/missing/ print $NF' inputfile > "missing.txt"
is what is wanted.
– glenn jackman
Jan 15 at 19:28
add a comment |
1
Or justgrep -F 'missing:' <inputfile >missing.txt
.
– Kusalananda
Jan 15 at 9:46
1
I suspectawk '/missing/ print $NF' inputfile > "missing.txt"
is what is wanted.
– glenn jackman
Jan 15 at 19:28
1
1
Or just
grep -F 'missing:' <inputfile >missing.txt
.– Kusalananda
Jan 15 at 9:46
Or just
grep -F 'missing:' <inputfile >missing.txt
.– Kusalananda
Jan 15 at 9:46
1
1
I suspect
awk '/missing/ print $NF' inputfile > "missing.txt"
is what is wanted.– glenn jackman
Jan 15 at 19:28
I suspect
awk '/missing/ print $NF' inputfile > "missing.txt"
is what is wanted.– glenn jackman
Jan 15 at 19:28
add a comment |
3
Please clarify what you mean by "trimming". Note that the code block that you have in your
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.– Kusalananda
Jan 15 at 6:44
You do not redirect your
LF
(n
) to the file.– kvantour
Jan 15 at 8:25
1
Please edit the question and add the expected output, otherwise we can just guess what you want to achieve as your awk script is not clear.
– RoVo
Jan 15 at 9:53
2
You probably see nothing because you get stuck in an infinite loop: the
do while
loop does not alterj
, so ifj == NF
, you're stuck. Did you check the file size of the final.txt file?– glenn jackman
Jan 15 at 19:26
What's in
final.txt
for the sample input?– roaima
Jan 15 at 22:48