linux - Sending 'awk' results of several files to new files with the same name -



linux - Sending 'awk' results of several files to new files with the same name -

i have folder contains text files. need extract 20 lines right after lastly word 'input' , send results files of same name in different folder

i utilize following:

for in error/*.log; awk '/input/ {n=nr} {a[nr]=$0} end {for (i=n;i<=n+20;i++) print a[i]}' $i > exceeded/`basename $i` done

what doing wrong?

thanks help in advance

if have spaces in file names (the * part of *.log) seek this:

for in error/*.log; awk '/input/ {n=nr} {a[nr]=$0} end {for (i=n;i<=n+20;i++) print a[i]}' "$i" > "exceeded/`basename \"$i\"`" ; done

also, assuming both "error" , "exceeded" directories in same directory (and "exceeded" exists.)

linux bash awk

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -