bash - awk script works on pure file, but dont work with tail+2 -


i have script gets maximum value of 3 columns of selected file. if file pure works good, if try pipe file tail+2 doesnt work anymore. there code:

 begin {max1 = 0; max2 = 0; max3 = 0} { if(max1 < $1) max1 = $1 if(max2 < $2) max2 = $2 if(max3 < $3) max3 = $3 } end {print max1, max2, max3;} 

i execute code : awk -f [codefilename] [targetfile]

works 100% good

i execute code (want remove first line before counting):

awk -f [codefilename] [targetfile] | tail+2

it fails

thank , time.

consider example:

awk -f codefilename targetfile | tail+2 

first of need space between tail , +2. secondly happening output awk command piped tail writing:

awk -f codefilename targetfile > tmp1 tail +2 tmp1 

what guess want take first line targetfile , run awk code on it, if that's case need:

tail +2 targetfile | awk -f codefilename 

afaik tail +n not supported distros, , need sed -n '2,$p' instead. if can clarify, please do.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -