Getting syntax error while running awk command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting syntax error while running awk command
# 1  
Old 07-03-2013
Getting syntax error while running awk command

Hello Gurus,

I am firing the below command :

Code:
df -g | grep -v var| awk '{ (if $4 > 90% ) print "Filesystem", $NF,"over sized";}'

But I am getting the below error:-
======
Code:
syntax error The source line is 1.
 The error context is
                {if ($4 > >>>  90%) <<<
 awk: The statement cannot be correctly parsed.
 The source line is 1.

Please suggest.

Thanks-
Pokhraj

Last edited by radoulov; 07-03-2013 at 05:56 AM..
# 2  
Old 07-03-2013
Code:
df -g | grep -v var| awk '{ if ( $4 > "90%" ) print "Filesystem", $NF,"over sized";}'

# 3  
Old 07-03-2013
Hello,


Could you please try theis following code and let me know if this helps.

Code:
 
$ df -g | grep -v "var" | awk '{sub(/\%/,"",$0)} {print$1" "$4}' | awk '{ if ( $2> "90" ) print $1 ,"over sized";}'
Filesystem over sized
/mnt over sized


Thanks,
R. Singh
# 4  
Old 07-03-2013
Thanks Anbu23 for your help.
But the command throwing some extra lines as below:-
======
Filesystem on over sized
Filesystem /febsmt/orasoft_bck over sized
Filesystem /febsdb/orasoft over sized

Why this line is coming.. Any idea.

Thank-
Pokhraj
# 5  
Old 07-03-2013
Code:
df -g | grep -v var| awk ' NR>1 { if ( $4 > "90%" ) print "Filesystem", $NF,"over sized";}'

# 6  
Old 07-03-2013
pkhraj_d,
check this out..
Code:
df -g | grep -v -e var -e Filesystem | sed 's/%/ /g'|awk '{ if ( $4 > 90 ) print "FILESYSTEM", $NF,"over sized";}'

Enjoy.
# 7  
Old 07-03-2013
Code:
df -g | grep -v var| awk '$4+0 > 90{print "Filesystem", $NF,"over sized"}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk: syntax error

awk -F, ' NR>1 { BEGIN{ chr=$2 } END{ for (k in chr) {print k} } } ' $gene_file I've a really simple code. I want to store gene name and it's chromosome and in the end print them. I'm skipping line one as it contains headers. But I don't know why I get error as: (2 Replies)
Discussion started by: genome
2 Replies

2. Shell Programming and Scripting

Syntax error in awk

I know the below code worked, but the syntax appears to be wrong and I can not seem to correct it. Thank you :). awk 'FNR==NR {E; next }>$3 in E {print $3, $5}' medical_exome__genes.txt RefSeqGene.txt > update.txt awk: cmd. line:1: FNR==NR {E; next }>$3 in E {print $3, $5} awk: cmd.... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

awk if else syntax error

Could somebody gently point out the error of my ways in the below (the flu I'm fighting might be contributing to my current haplessness) awk -F="\t" \ '{ for (i = 1; i <= NR; i++); FNR == i; { if (length($3) < 56 && length($1) > 56) $1=($1" "$2); $2=$3; $3=$4; ... (1 Reply)
Discussion started by: Andrew767
1 Replies

4. Shell Programming and Scripting

awk syntax error

Hi All, I wrote a simple script.sh program for i in seq (22) do awk '$1==${i}' file1.txt|awk '{print $2}'> file${i}_study.txt done and then run it %bash %chmod +x script.sh % ./script.sh Give me error awk: $1==${i} awk: ^ syntax error Do you have any idea why... (3 Replies)
Discussion started by: senayasma
3 Replies

5. Shell Programming and Scripting

awk syntax error

Hi, I can't see what is wrong with the following command. I am extracting a dollar amount (AMT_REJ, 6th field) from a comma delimited record and need to output it as numeric, removing the $sign and decimal point and output to another file. Everything seems to work except the $ sign which I need... (1 Reply)
Discussion started by: ski
1 Replies

6. Shell Programming and Scripting

awk command syntax

I want the output to show 2 lines following this line. How do I amend my awk command. Please guide. Thanks (3 Replies)
Discussion started by: Tirmazi
3 Replies

7. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

hi there i write one awk script file in shell programing the code is related to dd/mm/yy to month, day year format but i get an error please can anybody help me out in this problem ?????? i give my code here including error awk ` # date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies

8. UNIX for Dummies Questions & Answers

awk syntax error

I generate a fullpath variable two different ways: 1) concat two variables rootpath and relpath to give me fullpath 2) use 'find' to get the fullpath when I echo the variable, I get the same output for both. However, I print the variable from method 1 in the below loop I get "awk syntax... (0 Replies)
Discussion started by: orahi001
0 Replies

9. Shell Programming and Scripting

syntax error with awk.

A shell script a.sh calls an awk script using : awk -v OUTPUTDIR=${OUTPUTDIR}${OUTPUTDIRDATE} -f ${SCRIPTSPATH}chngNullBillId.awk ${INPUTFILE} chngNullBillId.awk : { if (substr($0,9,4)=="0000") printf( "%s0001%s", substr($0,1,8), substr($0,13,67) )>>${OUTPUTDIR}"goodfile.txt"; else print... (2 Replies)
Discussion started by: Amruta Pitkar
2 Replies

10. UNIX for Dummies Questions & Answers

awk syntax error

can anyone see the awk syntax error near line 1? I keep getting this error and I'm not familiar with awk very well yet so it is hard for me to see the errors. fyi: deleteuser* refers to files in the directory where each one ends with a different date ls -1 /mfupload/prod02/ftp/deleteuser* |... (12 Replies)
Discussion started by: k@ssidy
12 Replies
Login or Register to Ask a Question