AWK - HELP pls explain this ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting AWK - HELP pls explain this ?
# 1  
Old 01-15-2009
AWK - HELP pls explain this ?

Code:
echo "23.54" | awk '
function round(A) {
  return int( A + 0.5 )
}
{
printf("%d\n",round($1));
}'> > > > > >
awk: syntax error near line 2
awk: bailing out near line 2


Last edited by Franklin52; 01-15-2009 at 06:53 AM.. Reason: CODE TAGS
# 2  
Old 01-15-2009
Paste your code inside [ code] [ /code]. Remove space after [.
# 3  
Old 01-15-2009

My first guess is that you are running on Solaris and that you should be using nawk rather than awk.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Explain awk

I have 2 files recevied abc def ghi totallist abc 123 jasdhfaj def 345 fjdgkfsfh ghi 567 dfjdhdhfj jkl 678 djkahfdjshdf xyz 984 jdfdhfhdh myOutputFile jkl 678 djkahfdjshdf xyz 984 jdfdhfhdh I used this command for the output : awk 'FNR==NR {f1;next} !($1 in f1)' recevied... (2 Replies)
Discussion started by: nani1984
2 Replies

2. UNIX for Dummies Questions & Answers

netstat -an output, pls. explain..

Hi, I have old SCO O/S. System keeps crashing. I made lot of changes to kernel but so for nothing helped. I wrote a script which takes netstat -an output every one minute. I saw some thing right before the system crashed. Not sure if this means anything.. uname -a SCO_SV djx2 3.2... (2 Replies)
Discussion started by: samnyc
2 Replies

3. UNIX for Dummies Questions & Answers

Permissision issue, pls. explain

I have a directory, user name sam 755 drwxr-xr-x 3 sam oper 6 Apr 23 15:57 sam I log in as root, I can't write to sam folder. if the file already there, I can change that permission but it doesn't allow me to create any files in the above folder. Why, I thought root has... (2 Replies)
Discussion started by: samnyc
2 Replies

4. Shell Programming and Scripting

Explain this awk

found this handy one liner in another thread which is closed, it does what i need but im trying to understand it. it basically matches the field that contains the value v and prints its position awk -F, '{for(i=1;i<=NF;i++)if($i==v)print i}' v=yourfield inputfile my understanding is assign... (3 Replies)
Discussion started by: jack.bauer
3 Replies

5. Shell Programming and Scripting

Can Any people explain this awk command

Dear all , Can any people explain this awk command? What is the purpose of if (v++){b=$i;$i=""}? awk -F, '{for (i=1;i<=NF;i++){if (v++){b=$i;$i=""}};print $0} END { print "dups are" ;for ( i in b) print i}' OFS="," input_file This script is used to replace column duplicate value ... (1 Reply)
Discussion started by: eldonlck
1 Replies

6. Shell Programming and Scripting

Please explain what this Awk code is doing

Hi Guys, Please help me, I am new to programming and I don’t understand what some parts of this code are doing. I have comments on the parts I know, please help if my understanding of the code is not correct and also help with parts with questions. awk ' { gsub( ">",... (1 Reply)
Discussion started by: James_Owen
1 Replies

7. UNIX for Dummies Questions & Answers

Please explain this simple AWK example

awk '!_++' Most importantly, I want to know what the underscore does "!_" But ideally, please breakdown the whole thing. It is supposed to remove duplicate lines when found in a file. (1 Reply)
Discussion started by: glev2005
1 Replies

8. Shell Programming and Scripting

scripting/awk help : awk sum output is not comming in regular format. Pls advise.

Hi Experts, I am adding a column of numbers with awk , however not getting correct output: # awk '{sum+=$1} END {print sum}' datafile 2.15291e+06 How can I getthe output like : 2152910 Thank you.. # awk '{sum+=$1} END {print sum}' datafile 2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies

9. Shell Programming and Scripting

plese explain awk '{print \$NF}'

please explain this awk '{print \$NF}' i have a command grep -i adding /logs/eap | grep -iv equation | awk '{print \$NF}' | sort -u | sed 's/\.\$//' >> /temp/t please explain the above awk and sed as well how it works and also what is \$NF (1 Reply)
Discussion started by: mail2sant
1 Replies

10. Shell Programming and Scripting

Explain awk

Hi, I found this command in this forum, but, couldnt understand much from it. could any one help me understand that??? the commands are : awk '{sub(/ ~/,""); printf $0 ($0~/\|$/?ORS:"")}' file1 > file2 awk '{sub(/~ */,x);printf $0(/\|$/?ORS:x)}' awk '{sub(/~ */,x);sub(/\|$/, "|\n")}8'... (4 Replies)
Discussion started by: hitmansilentass
4 Replies
Login or Register to Ask a Question