...
...
I am using the following command to get the sum and it is working correctly but I am getting syntax error as well.
(Tried with bc -l as well)
Syntax error received for every line numbers.
(standard_in) 3: syntax error
...
While I agree with vgersh99 that you don't need bc when you are using awk anyway (since awk can perform the summation itself), I was curious to know what exactly is causing the error.
Looks like you are generating a bunch of "bc" commands that you pipe into bc.
With a sample file that has floating point numbers in it, I tried your code in my system that consists of Cygwin 1.6.10, GNU bash 3.2.39, GNU awk 3.1.6, GNU bc 1.06.
And inside a shell script, the logic works well:
So it looks like there is something wrong with the data in that "temp.hash.txt" file.
Apparently, "bc" balks at line number 3:
which would be the line in red below:
So if I change the 2nd line of "temp.hash.txt", I am able to reproduce your error:
In the shell script as well:
So I'd guess that maybe line # 2 of your temp.hash.txt does not have an integer or float(?)
Due to some syntax error, my below code is not working.
#!/usr/bin/ksh
nawk '
BEGIN {
cur_val=0; cur_zero=0; cur_nine=0;
sum_zero=0; sum_nine=0;
}
/^/ {
cur_val=substr($0,5,2);
if("cur_val" == "0")
{
... (3 Replies)
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)
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)
I have a file called test.dat which contains
a b
I have written a shell script called test.sh
for i in `cat test.dat`
do
echo $i
done
When i run this script using
sh test.sh
I get this message -
test.sh: syntax error at line 6: `end of file' unexpected
What is the... (3 Replies)
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)
Can anyone work out why this line has a syntax error?
awk '{if ($1==1) print NR,$0 } '${PROJECT}/${data_dir}/${ofolder}/STDEV/otimes_${per}_secs.dat > tmp2.txt
I've check that the file exists in the given location (1 Reply)
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)