Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie in awk

Status
Not open for further replies.

wally1

Technical User
Mar 24, 2003
27
IT
Hi i am a newbie in awk,
this is the first script that i try to run but i have made a mistake because i haven't output on my screen.
Please this is my little awk program :

#! /bin/ksh
ls -l | awk '$5 == "Aug" { sum = sum+$4 } END { print SUM}'

i run this script with this command
> ./pippo.ksh

Anyone can help me to find the error ?????
Walter


 
AWK is case-sensitive, so try

print sum

at the end
 
Ok i put sum but i haven't the output.
Why ????
Walter
 
I have made a mistake to count the fields in a generic record of output of ls -l command.
Now is ok all
Thanks all
Walter

 
Wally,

Awk is case sensitive. Look at your variables for "sum" and then you are using "SUM" to print it out which will give you blank results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top