What is wrong with my awk code?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What is wrong with my awk code?
# 8  
Old 10-24-2014
Alright, just to make sure, could can you copy and paste this code right onto your bash command line ?
Code:
awk '($4 >= 39.10 && $4 <= 39.64) && ($3 >= 32.75 && $3 <= 33.28) {print $0}' << "EOF"
20100213 102212 33.1185 39.4078 2.9
20100214 141753 33.1058 39.9068 2.9
20100218 115828 33.1907 39.3575 2.9
20100225 220001 33.1932 39.9448 2.9
20100226 152045 32.0103 39.3327 2.9
20100228 204455 33.1685 39.3558 2.9
20100323 081029 33.9345 39.9825 2.9
20100328 074927 32.8845 38.7272 2.9
20100330 034504 33.159 38.4325 2.9
20100413 071614 32.959 38.698 2.9
20100427 221931 33.0723 39.4485 2.9
20100524 010333 33.1305 39.3832 2.9
20100928 222019 33.3445 38.938 2.9
20101012 145522 34.0737 38.3135 2.9
20101020 051633 34.7478 38.154 2.9
20101024 232138 34.6318 39.5025 2.9
20101102 141258 32.0048 39.6565 2.9
20110207 140450 33.4383 39.9757 2.9
20110219 140734 34.2425 38.343 2.9
20110227 081313 33.1547 39.3738 2.9
EOF

It should produce this:
Code:
20100213 102212 33.1185 39.4078 2.9
20100218 115828 33.1907 39.3575 2.9
20100228 204455 33.1685 39.3558 2.9
20100427 221931 33.0723 39.4485 2.9
20100524 010333 33.1305 39.3832 2.9
20110227 081313 33.1547 39.3738 2.9


Last edited by Scrutinizer; 10-24-2014 at 09:43 PM..
# 9  
Old 10-27-2014
Quote:
Originally Posted by Scrutinizer
Alright, just to make sure, could can you copy and paste this code right onto your bash command line ?
Code:
awk '($4 >= 39.10 && $4 <= 39.64) && ($3 >= 32.75 && $3 <= 33.28) {print $0}' << "EOF"
20100213 102212 33.1185 39.4078 2.9
20100214 141753 33.1058 39.9068 2.9
20100218 115828 33.1907 39.3575 2.9
20100225 220001 33.1932 39.9448 2.9
20100226 152045 32.0103 39.3327 2.9
20100228 204455 33.1685 39.3558 2.9
20100323 081029 33.9345 39.9825 2.9
20100328 074927 32.8845 38.7272 2.9
20100330 034504 33.159 38.4325 2.9
20100413 071614 32.959 38.698 2.9
20100427 221931 33.0723 39.4485 2.9
20100524 010333 33.1305 39.3832 2.9
20100928 222019 33.3445 38.938 2.9
20101012 145522 34.0737 38.3135 2.9
20101020 051633 34.7478 38.154 2.9
20101024 232138 34.6318 39.5025 2.9
20101102 141258 32.0048 39.6565 2.9
20110207 140450 33.4383 39.9757 2.9
20110219 140734 34.2425 38.343 2.9
20110227 081313 33.1547 39.3738 2.9
EOF

It should produce this:
Code:
20100213 102212 33.1185 39.4078 2.9
20100218 115828 33.1907 39.3575 2.9
20100228 204455 33.1685 39.3558 2.9
20100427 221931 33.0723 39.4485 2.9
20100524 010333 33.1305 39.3832 2.9
20110227 081313 33.1547 39.3738 2.9


Sorry for my late reply due to weekend.

I have noticed that this problem happens when I connect to Centos machine through ssh from my ubuntu desktop (That is how I work). Copying and pating into terminal as you suggested also not working.

However, when I run the code on the terminal of the Centos machine it is working!

Later on I tried to ssh from my Windows machine to Centos in order to see if the problem caused by SSH. To my suprise the code works without a problem!

So in summary, it seems my awk code doesn't work when I connect to Centos machine via SSH from my Ubuntu desktop. It is strange. By the way the code works perfectly on ubuntu itself Smilie

So do you guys have any theories about this?
# 10  
Old 10-27-2014
Interesting. Maybe a TERM setting? What does $TERM contain before and after you ssh from your Ubuntu desktop to Centos? What desktop are you using on Ubuntu?
# 11  
Old 10-28-2014
Quote:
Originally Posted by Scrutinizer
Interesting. Maybe a TERM setting? What does $TERM contain before and after you ssh from your Ubuntu desktop to Centos? What desktop are you using on Ubuntu?
I am using unity as a desktop on my Ubuntu 14.04. TERM variable shows "xterm" before and after.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What's wrong with my awk

file1: maximum_delay time: 102.794 ms maximum_delay time: 92.977 ms maximum_delay time: 98.895 ms maximum_delay time: 96.891 ms maximum_delay time: 86.966 ms maximum_delay time: 95.91 ms maximum_delay time: 98.921 ms maximum_delay time: 89.881 ms maximum_delay time: 92.931 ms... (1 Reply)
Discussion started by: yanglei_fage
1 Replies

2. Shell Programming and Scripting

What is wrong with my code?

Hello, all Suppose my current directory has 3 files: file_1 file_2 file_3 I wrote the following codes: awk 'BEGIN{while("ls"|getline d) {myarray++}}; END{close("ls");for (i in myarray){print i, myarray}}' /dev/null I expect the output be like: 1 file_1 2 file_2 3 file_3 ... (7 Replies)
Discussion started by: littlewenwen
7 Replies

3. Shell Programming and Scripting

What's wrong with this awk?

I have a file and if I'm doing following action on that file it's coming up correctly awk -F"," '/DATA_TYPE/ { cnt += $3 } END { print " DATA_TYPE count=" cnt}' inter DATA_TYPE count=19593131 now if I'm changing same AWK, so that now it can accept variable, then it's somehow not working.... (3 Replies)
Discussion started by: manas_ranjan
3 Replies

4. Shell Programming and Scripting

what's wrong with my awk

echo "abc:bcd" |awk '{split($0,b,":");print "b" is good }' I want to "bcd" is good , anything is wrong with my, please don't change my thought with split, I just want to know what's wrong :o (1 Reply)
Discussion started by: yanglei_fage
1 Replies

5. Shell Programming and Scripting

What's wrong with this awk?

ZSCORE=$(awk "BEGIN {if($STDEVIATE>0) {print ZSCORER=$(awk "BEGIN{print (${ALL} - ${AVERAGE}) / ${STDEVIATE}}")}else print "0"}") awk: fatal: division by zero attempted awk: BEGIN {if(0==0) {print ZSCORER=}else print 0} awk: ^ syntax error ALL=9 STDEVIATE=0... (2 Replies)
Discussion started by: SkySmart
2 Replies

6. Shell Programming and Scripting

awk... what is wrong?

Hi there, what is wrong with this? grep ">>" alarms_temp | awk '{print substr($5, 2), $7}' | read var1 var2 echo "$var1" echo "$var2" Both variable are empty, but if i run: grep ">>" alarms_temp | awk '{print substr($5, 2), $7}' I have: 0 9 as a result. (2 Replies)
Discussion started by: marimovo
2 Replies

7. Shell Programming and Scripting

What's wrong with this code?

Trying to do a file count on files between a specific date. I entered the following command, but it's not working: find . -type f \( -newer startdate -a ! -newer enddate \) -exec "ls -l | wc -l" {} \; lil help? :D (4 Replies)
Discussion started by: bbbngowc
4 Replies

8. Shell Programming and Scripting

What is wrong with this code

I just wanted to assign the filename to a variable filename="abc" datestrng=`date +%Y%m%d` filextn="txt" "LOCAL_FILE"${i}=${filename}"_"${datestrng}"."${filextn} echo "LOCAL_FILE"${i} I get the following error on 2nd last line ksh: LOCAL_FILE1=abc_20081114.txt: not... (3 Replies)
Discussion started by: mqasim
3 Replies

9. Shell Programming and Scripting

What's wrong with this code?

Hello all, Can someone tell me why I'm getting an error in the following code: export return_code="$?" if then echo "load_shaw.sas failed." exit else echo "Trigger the next script..." # /path/to/next/script fi I get an error... (3 Replies)
Discussion started by: mmignot
3 Replies

10. UNIX for Dummies Questions & Answers

What is wrong with this code?

Hello everyone, can somebody tell me what is wrong with this code: while true do java myTime > myTime.log sleep 60 done I get the following error: ./myTime: Syntax error at line 1 : `while' is not matched. Thanks in advance! (6 Replies)
Discussion started by: Lem2003
6 Replies
Login or Register to Ask a Question