Division By 0 Error Token Is
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up “Division by Zero” error in bash/awk (probably syntax) up vote 1 down vote favorite 1 I have a .tsv file that's continuously updated (i.e. every 5 minutes) with data. I'm trying to write a shell script which, when executed, identifies the rows in the .tsv file it hasn't seen yet, manipulates each row, and appends the new rows to a different file. I've only done a very little shell scripting before, and this is my first time using awk, which is doing most of the actual processing of data. When I try to run my script, I get this error: line 21: 0 /var/www/processed-temp-data: division by 0 (error token is "/www/processed-temp-data") Line 21 is where I invoke awk: awk -v awkLINES=$((LINES+1)) -v q="'" 'function CtoF(tempC) { 1.8 * tempC + 32 } function make-dTime(tsvTime) { split(tsvTime, dTime, /:_-/, seps) jsMonth = dTime[2] - 1 dTime[1] ", " jsMonth ", " dTime[3] ", " dTime[4] ", " dTime[5] ", " dTime[6] } # skips past the lines already in output file NR <= awkLINES { next } # formats data { print "{c:[{v: new Date(" make-dTime($1) ")}, {v: q" CtoF($2) $2 "q}, {v: q" $3 "q}]}," }' /home/pi/dht-temp-log.tsv >>/var/www/processed-temp-data Since I don't want to be doing any division at all, clearly something's going wrong. I expect I've made some sort of mistake with quoting or escape sequences or something, but I've been having a terrible time trying to pin down exactly what. Help would be greatly appreciated. ETA A line of input would look like: 2014-12-22_14:35:08 27.5 14.1 That should be converted to {c:[{v: new Date(2014, 11, 22, 14, 25, 08)}, {v: '81.5'}, {v: '27.5'}, {v: '14.1'}]}, bash shell awk share|improve this question edited Dec 3 '14 at 6:19 asked Dec 3 '14 at 5:59 LiberalArtist 1207 add a comment| 2 Answe
Search HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie Division by 0 error User Name Remember Me? Password Linux - Newbie This Linux forum is for members that are new to Linux. Just starting out and have a question? If it is not in the man pages or the how-to's this is the place! Notices Welcome to LinuxQuestions.org, a friendly and active Linux Community. You are currently viewing LQ as a guest. By joining http://stackoverflow.com/questions/27264720/division-by-zero-error-in-bash-awk-probably-syntax our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today! Note that registered members see fewer ads, and ContentLink is completely disabled once you log in. Are you new to LinuxQuestions.org? Visit the http://www.linuxquestions.org/questions/linux-newbie-8/division-by-0-error-699202/ following links: Site Howto | Site FAQ | Sitemap | Register Now If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here. Having a problem logging in? Please visit this page to clear all LQ-related cookies. Introduction to Linux - A Hands on Guide This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own. Click Here to receive this Complete Guide absolutely free. Search th
Get Kubuntu Get Xubuntu Get Lubuntu Get UbuntuStudio Get Mythbuntu Get Edubuntu Get Ubuntu-GNOME Get UbuntuKylin Ubuntu Code of Conduct Ubuntu Wiki Community Wiki Other Support Launchpad Answers Ubuntu IRC Support https://ubuntuforums.org/showthread.php?t=394707 AskUbuntu Official Documentation User Documentation Social Media Facebook Twitter Useful Links Distrowatch Bugs: Ubuntu PPAs: Ubuntu Web Upd8: Ubuntu OMG! Ubuntu Ubuntu Insights Planet Ubuntu Activity Page Please read before SSO login Advanced Search Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk BASH Scripts -- my first and ideas for more Having an Issue With Posting ? Do you want to help us division by debug the posting issues ? < is the place to report it, thanks ! Results 1 to 10 of 10 Thread: BASH Scripts -- my first and ideas for more Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode March 27th, 2007 #1 trevorv View Profile View Forum Posts Private Message Just Give Me the Beans! Join Date division by 0 Nov 2005 Location Isle of Wight, England Beans 63 DistroUbuntu 6.06 BASH Scripts -- my first and ideas for more Hiya! I'm learning BASH scripting at the moment, and I've just written my first script to display a random background image -- I didn't like any of the existing scripts which did the same job, the ones I've seen seem to needlessly deal in temporary files and excess functions. Anyway, I thought I'd post it here, and ask anyone to point out anything wrong with it -- I don't want to get into bad habits this early! Code: #set $bgdir to dir containing background images bgdir=~/images #set $bgs to a list of background images bgs=($bgdir/*) #set $bgnum to amount of backgrounds bgnum=${#bgs[@]} #set random number random=$RANDOM let "random %= $bgnum" #set background image feh --bg-scale ${bgs[$random]} Also, I was hoping you guys could suggest some interesting scripts to write that might actually come in useful, it's all well and good trawling through the examples in the books and howtos, but it's a lot more interesting if you get something out of it at the end. Thanks! Running Ubuntu on a cheap but rock-solid Thinkpad R50e. Adv Reply March 27th, 2007 #2 Poisson_P