How do you calculate sum of a column without creating temp files in shell script?
up vote
1
down vote
favorite
given an input file with data like this:
id,name
10,abc
20,xyz
30,def
I am trying to sum the values in the id column.
Note: the reason I am using awk -v header is because I have multiple files all of which have id as a common header name but at different positions.
The output I am expecting is the total sum of id (i.e., for the example above the output is 60).
The code below works and returns the expected output, but I have to create a temp file in the code and then calculate the sum.
I tried many variations unfortunately all my efforts failed.
I want to avoid writing the data to a temp file, intfile.txt, but I am stuck.
Any solutions/suggestions appreciated.
ps: I am relatively new to shell scripting and I know code is not written well, but I am working through it.
#!/bin/bash
awk -v header="id" '
BEGIN { FS=","; a=0 }
NR == 1 { for (i=1;i<=NF;i++) { if ($i==header) { a=i }} }
a=NR > 1 && a>0 { print $a }' testfile.txt>intfile.txt
awk '{s+=$1}END{print s}' intfile.txt
shell
add a comment |
up vote
1
down vote
favorite
given an input file with data like this:
id,name
10,abc
20,xyz
30,def
I am trying to sum the values in the id column.
Note: the reason I am using awk -v header is because I have multiple files all of which have id as a common header name but at different positions.
The output I am expecting is the total sum of id (i.e., for the example above the output is 60).
The code below works and returns the expected output, but I have to create a temp file in the code and then calculate the sum.
I tried many variations unfortunately all my efforts failed.
I want to avoid writing the data to a temp file, intfile.txt, but I am stuck.
Any solutions/suggestions appreciated.
ps: I am relatively new to shell scripting and I know code is not written well, but I am working through it.
#!/bin/bash
awk -v header="id" '
BEGIN { FS=","; a=0 }
NR == 1 { for (i=1;i<=NF;i++) { if ($i==header) { a=i }} }
a=NR > 1 && a>0 { print $a }' testfile.txt>intfile.txt
awk '{s+=$1}END{print s}' intfile.txt
shell
2
Embedding a big awk script is hardly doing things "in shell script" -- you might as well have your shell script just call a Python interpreter. :)
– Charles Duffy
Nov 8 at 0:56
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
given an input file with data like this:
id,name
10,abc
20,xyz
30,def
I am trying to sum the values in the id column.
Note: the reason I am using awk -v header is because I have multiple files all of which have id as a common header name but at different positions.
The output I am expecting is the total sum of id (i.e., for the example above the output is 60).
The code below works and returns the expected output, but I have to create a temp file in the code and then calculate the sum.
I tried many variations unfortunately all my efforts failed.
I want to avoid writing the data to a temp file, intfile.txt, but I am stuck.
Any solutions/suggestions appreciated.
ps: I am relatively new to shell scripting and I know code is not written well, but I am working through it.
#!/bin/bash
awk -v header="id" '
BEGIN { FS=","; a=0 }
NR == 1 { for (i=1;i<=NF;i++) { if ($i==header) { a=i }} }
a=NR > 1 && a>0 { print $a }' testfile.txt>intfile.txt
awk '{s+=$1}END{print s}' intfile.txt
shell
given an input file with data like this:
id,name
10,abc
20,xyz
30,def
I am trying to sum the values in the id column.
Note: the reason I am using awk -v header is because I have multiple files all of which have id as a common header name but at different positions.
The output I am expecting is the total sum of id (i.e., for the example above the output is 60).
The code below works and returns the expected output, but I have to create a temp file in the code and then calculate the sum.
I tried many variations unfortunately all my efforts failed.
I want to avoid writing the data to a temp file, intfile.txt, but I am stuck.
Any solutions/suggestions appreciated.
ps: I am relatively new to shell scripting and I know code is not written well, but I am working through it.
#!/bin/bash
awk -v header="id" '
BEGIN { FS=","; a=0 }
NR == 1 { for (i=1;i<=NF;i++) { if ($i==header) { a=i }} }
a=NR > 1 && a>0 { print $a }' testfile.txt>intfile.txt
awk '{s+=$1}END{print s}' intfile.txt
shell
shell
edited Nov 8 at 0:47
David Yates
650823
650823
asked Nov 8 at 0:23
kumarm
64
64
2
Embedding a big awk script is hardly doing things "in shell script" -- you might as well have your shell script just call a Python interpreter. :)
– Charles Duffy
Nov 8 at 0:56
add a comment |
2
Embedding a big awk script is hardly doing things "in shell script" -- you might as well have your shell script just call a Python interpreter. :)
– Charles Duffy
Nov 8 at 0:56
2
2
Embedding a big awk script is hardly doing things "in shell script" -- you might as well have your shell script just call a Python interpreter. :)
– Charles Duffy
Nov 8 at 0:56
Embedding a big awk script is hardly doing things "in shell script" -- you might as well have your shell script just call a Python interpreter. :)
– Charles Duffy
Nov 8 at 0:56
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
#!/usr/bin/env bash
target="id" # the field you want to sum
target_idx= # the column number of that field
sum=0 # the sum that was found so far
{
# first, just read the header...
IFS=, read -r -a header
for idx in "${!header[@]}"; do # and look for the target field in it
[[ ${header[$idx]} = $target ]] && { target_idx=$idx; break; }
done
[[ $target_idx ]] || { echo "ERROR: No $target field found" >&2; exit 1; }
# then, iterate over other lines
while IFS=, read -r -a line; do
sum=$(( sum + ${line[$target_idx]} ))
done
} <testfile.txt
echo "$sum"
See this running at https://ideone.com/MOnpFM
Some references:
- The basics of reading a file line-by-line by calling
read
repeatedly are covered in BashFAQ #1. - Fancy array syntax (including the parameter expansion
"${!array[@]}"
to iterate over indices) is covered in the bash-hackers' page on arrays, BashFAQ #5, and also the BashGuide array page. - Arithmetic syntax (
$(( ... ))
for math) is covered in the bash-hackers' wiki at http://wiki.bash-hackers.org/syntax/arith_expr
Thank-you for your time. quick question how do I pass my input file name to the script mentioned
– kumarm
Nov 8 at 1:02
Personally, I'd just take out the<testfile.txt
from inside the script and connect the input to stdin; thus, invoking it as./yourscript <"$realInputFileName"
(assumingrealInputFileName
is a variable that holds, well, the input file's name).
– Charles Duffy
Nov 8 at 1:03
...actually, if you're no longer doing redirection inside the script, you don't need the{
and}
at all (since all they do is scope that redirection, such that stdin comes from the file within that block).
– Charles Duffy
Nov 8 at 1:08
Thanks Charles Duffy the code works. I had to comment out the line [[ $target_idx ]] || { echo "ERROR: No $target field found" >&2; exit 1; } for some reason i was getting echo not found. Now I will try to go through the code line by line and try to understand it to the best of my ability.
– kumarm
Nov 8 at 2:12
Can you reproduce that not-found error on an online interpreter (like how I have an example where you can see the code working at ideone.com)? Anyhow, let me know if you have questions that aren't covered in the references section and I'll add more links as appropriate.
– Charles Duffy
Nov 8 at 4:18
|
show 7 more comments
up vote
0
down vote
Try this also:
idline=$(grep id input.txt)
IFS=',' read -ra elem <<< "$idline"
idfld=0
for i in "${elem[@]}"; do
idfld=$(($idfld+1))
if [[ "$i" = "id" ]]
then
break;
fi
done
gt=0
for num in `cat input.txt|grep "^[0-9]"|cut -d"," -f${idfld}`; do
gt=$(($gt+$num ))
done
echo $gt
Thanks but this would not work in my case as I do not know which field/position id column would be.
– kumarm
Nov 8 at 1:58
Hi this is the error i am facing when i try this warning: here-document at line 3 delimited by end-of-file (wanted `$idline') I think its because of some un printable characters or the online bash terminal I am using. i will try it out tomorrow when i go to office and revert back to you.Thanks for the time
– kumarm
Nov 8 at 3:31
Sorry for the delay @sam yes your script works it gave an error saying cut starts at position 1 so i made some changes but it works thanks.
– kumarm
Nov 10 at 18:10
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
#!/usr/bin/env bash
target="id" # the field you want to sum
target_idx= # the column number of that field
sum=0 # the sum that was found so far
{
# first, just read the header...
IFS=, read -r -a header
for idx in "${!header[@]}"; do # and look for the target field in it
[[ ${header[$idx]} = $target ]] && { target_idx=$idx; break; }
done
[[ $target_idx ]] || { echo "ERROR: No $target field found" >&2; exit 1; }
# then, iterate over other lines
while IFS=, read -r -a line; do
sum=$(( sum + ${line[$target_idx]} ))
done
} <testfile.txt
echo "$sum"
See this running at https://ideone.com/MOnpFM
Some references:
- The basics of reading a file line-by-line by calling
read
repeatedly are covered in BashFAQ #1. - Fancy array syntax (including the parameter expansion
"${!array[@]}"
to iterate over indices) is covered in the bash-hackers' page on arrays, BashFAQ #5, and also the BashGuide array page. - Arithmetic syntax (
$(( ... ))
for math) is covered in the bash-hackers' wiki at http://wiki.bash-hackers.org/syntax/arith_expr
Thank-you for your time. quick question how do I pass my input file name to the script mentioned
– kumarm
Nov 8 at 1:02
Personally, I'd just take out the<testfile.txt
from inside the script and connect the input to stdin; thus, invoking it as./yourscript <"$realInputFileName"
(assumingrealInputFileName
is a variable that holds, well, the input file's name).
– Charles Duffy
Nov 8 at 1:03
...actually, if you're no longer doing redirection inside the script, you don't need the{
and}
at all (since all they do is scope that redirection, such that stdin comes from the file within that block).
– Charles Duffy
Nov 8 at 1:08
Thanks Charles Duffy the code works. I had to comment out the line [[ $target_idx ]] || { echo "ERROR: No $target field found" >&2; exit 1; } for some reason i was getting echo not found. Now I will try to go through the code line by line and try to understand it to the best of my ability.
– kumarm
Nov 8 at 2:12
Can you reproduce that not-found error on an online interpreter (like how I have an example where you can see the code working at ideone.com)? Anyhow, let me know if you have questions that aren't covered in the references section and I'll add more links as appropriate.
– Charles Duffy
Nov 8 at 4:18
|
show 7 more comments
up vote
0
down vote
accepted
#!/usr/bin/env bash
target="id" # the field you want to sum
target_idx= # the column number of that field
sum=0 # the sum that was found so far
{
# first, just read the header...
IFS=, read -r -a header
for idx in "${!header[@]}"; do # and look for the target field in it
[[ ${header[$idx]} = $target ]] && { target_idx=$idx; break; }
done
[[ $target_idx ]] || { echo "ERROR: No $target field found" >&2; exit 1; }
# then, iterate over other lines
while IFS=, read -r -a line; do
sum=$(( sum + ${line[$target_idx]} ))
done
} <testfile.txt
echo "$sum"
See this running at https://ideone.com/MOnpFM
Some references:
- The basics of reading a file line-by-line by calling
read
repeatedly are covered in BashFAQ #1. - Fancy array syntax (including the parameter expansion
"${!array[@]}"
to iterate over indices) is covered in the bash-hackers' page on arrays, BashFAQ #5, and also the BashGuide array page. - Arithmetic syntax (
$(( ... ))
for math) is covered in the bash-hackers' wiki at http://wiki.bash-hackers.org/syntax/arith_expr
Thank-you for your time. quick question how do I pass my input file name to the script mentioned
– kumarm
Nov 8 at 1:02
Personally, I'd just take out the<testfile.txt
from inside the script and connect the input to stdin; thus, invoking it as./yourscript <"$realInputFileName"
(assumingrealInputFileName
is a variable that holds, well, the input file's name).
– Charles Duffy
Nov 8 at 1:03
...actually, if you're no longer doing redirection inside the script, you don't need the{
and}
at all (since all they do is scope that redirection, such that stdin comes from the file within that block).
– Charles Duffy
Nov 8 at 1:08
Thanks Charles Duffy the code works. I had to comment out the line [[ $target_idx ]] || { echo "ERROR: No $target field found" >&2; exit 1; } for some reason i was getting echo not found. Now I will try to go through the code line by line and try to understand it to the best of my ability.
– kumarm
Nov 8 at 2:12
Can you reproduce that not-found error on an online interpreter (like how I have an example where you can see the code working at ideone.com)? Anyhow, let me know if you have questions that aren't covered in the references section and I'll add more links as appropriate.
– Charles Duffy
Nov 8 at 4:18
|
show 7 more comments
up vote
0
down vote
accepted
up vote
0
down vote
accepted
#!/usr/bin/env bash
target="id" # the field you want to sum
target_idx= # the column number of that field
sum=0 # the sum that was found so far
{
# first, just read the header...
IFS=, read -r -a header
for idx in "${!header[@]}"; do # and look for the target field in it
[[ ${header[$idx]} = $target ]] && { target_idx=$idx; break; }
done
[[ $target_idx ]] || { echo "ERROR: No $target field found" >&2; exit 1; }
# then, iterate over other lines
while IFS=, read -r -a line; do
sum=$(( sum + ${line[$target_idx]} ))
done
} <testfile.txt
echo "$sum"
See this running at https://ideone.com/MOnpFM
Some references:
- The basics of reading a file line-by-line by calling
read
repeatedly are covered in BashFAQ #1. - Fancy array syntax (including the parameter expansion
"${!array[@]}"
to iterate over indices) is covered in the bash-hackers' page on arrays, BashFAQ #5, and also the BashGuide array page. - Arithmetic syntax (
$(( ... ))
for math) is covered in the bash-hackers' wiki at http://wiki.bash-hackers.org/syntax/arith_expr
#!/usr/bin/env bash
target="id" # the field you want to sum
target_idx= # the column number of that field
sum=0 # the sum that was found so far
{
# first, just read the header...
IFS=, read -r -a header
for idx in "${!header[@]}"; do # and look for the target field in it
[[ ${header[$idx]} = $target ]] && { target_idx=$idx; break; }
done
[[ $target_idx ]] || { echo "ERROR: No $target field found" >&2; exit 1; }
# then, iterate over other lines
while IFS=, read -r -a line; do
sum=$(( sum + ${line[$target_idx]} ))
done
} <testfile.txt
echo "$sum"
See this running at https://ideone.com/MOnpFM
Some references:
- The basics of reading a file line-by-line by calling
read
repeatedly are covered in BashFAQ #1. - Fancy array syntax (including the parameter expansion
"${!array[@]}"
to iterate over indices) is covered in the bash-hackers' page on arrays, BashFAQ #5, and also the BashGuide array page. - Arithmetic syntax (
$(( ... ))
for math) is covered in the bash-hackers' wiki at http://wiki.bash-hackers.org/syntax/arith_expr
edited Nov 8 at 1:07
answered Nov 8 at 0:51
Charles Duffy
170k24193247
170k24193247
Thank-you for your time. quick question how do I pass my input file name to the script mentioned
– kumarm
Nov 8 at 1:02
Personally, I'd just take out the<testfile.txt
from inside the script and connect the input to stdin; thus, invoking it as./yourscript <"$realInputFileName"
(assumingrealInputFileName
is a variable that holds, well, the input file's name).
– Charles Duffy
Nov 8 at 1:03
...actually, if you're no longer doing redirection inside the script, you don't need the{
and}
at all (since all they do is scope that redirection, such that stdin comes from the file within that block).
– Charles Duffy
Nov 8 at 1:08
Thanks Charles Duffy the code works. I had to comment out the line [[ $target_idx ]] || { echo "ERROR: No $target field found" >&2; exit 1; } for some reason i was getting echo not found. Now I will try to go through the code line by line and try to understand it to the best of my ability.
– kumarm
Nov 8 at 2:12
Can you reproduce that not-found error on an online interpreter (like how I have an example where you can see the code working at ideone.com)? Anyhow, let me know if you have questions that aren't covered in the references section and I'll add more links as appropriate.
– Charles Duffy
Nov 8 at 4:18
|
show 7 more comments
Thank-you for your time. quick question how do I pass my input file name to the script mentioned
– kumarm
Nov 8 at 1:02
Personally, I'd just take out the<testfile.txt
from inside the script and connect the input to stdin; thus, invoking it as./yourscript <"$realInputFileName"
(assumingrealInputFileName
is a variable that holds, well, the input file's name).
– Charles Duffy
Nov 8 at 1:03
...actually, if you're no longer doing redirection inside the script, you don't need the{
and}
at all (since all they do is scope that redirection, such that stdin comes from the file within that block).
– Charles Duffy
Nov 8 at 1:08
Thanks Charles Duffy the code works. I had to comment out the line [[ $target_idx ]] || { echo "ERROR: No $target field found" >&2; exit 1; } for some reason i was getting echo not found. Now I will try to go through the code line by line and try to understand it to the best of my ability.
– kumarm
Nov 8 at 2:12
Can you reproduce that not-found error on an online interpreter (like how I have an example where you can see the code working at ideone.com)? Anyhow, let me know if you have questions that aren't covered in the references section and I'll add more links as appropriate.
– Charles Duffy
Nov 8 at 4:18
Thank-you for your time. quick question how do I pass my input file name to the script mentioned
– kumarm
Nov 8 at 1:02
Thank-you for your time. quick question how do I pass my input file name to the script mentioned
– kumarm
Nov 8 at 1:02
Personally, I'd just take out the
<testfile.txt
from inside the script and connect the input to stdin; thus, invoking it as ./yourscript <"$realInputFileName"
(assuming realInputFileName
is a variable that holds, well, the input file's name).– Charles Duffy
Nov 8 at 1:03
Personally, I'd just take out the
<testfile.txt
from inside the script and connect the input to stdin; thus, invoking it as ./yourscript <"$realInputFileName"
(assuming realInputFileName
is a variable that holds, well, the input file's name).– Charles Duffy
Nov 8 at 1:03
...actually, if you're no longer doing redirection inside the script, you don't need the
{
and }
at all (since all they do is scope that redirection, such that stdin comes from the file within that block).– Charles Duffy
Nov 8 at 1:08
...actually, if you're no longer doing redirection inside the script, you don't need the
{
and }
at all (since all they do is scope that redirection, such that stdin comes from the file within that block).– Charles Duffy
Nov 8 at 1:08
Thanks Charles Duffy the code works. I had to comment out the line [[ $target_idx ]] || { echo "ERROR: No $target field found" >&2; exit 1; } for some reason i was getting echo not found. Now I will try to go through the code line by line and try to understand it to the best of my ability.
– kumarm
Nov 8 at 2:12
Thanks Charles Duffy the code works. I had to comment out the line [[ $target_idx ]] || { echo "ERROR: No $target field found" >&2; exit 1; } for some reason i was getting echo not found. Now I will try to go through the code line by line and try to understand it to the best of my ability.
– kumarm
Nov 8 at 2:12
Can you reproduce that not-found error on an online interpreter (like how I have an example where you can see the code working at ideone.com)? Anyhow, let me know if you have questions that aren't covered in the references section and I'll add more links as appropriate.
– Charles Duffy
Nov 8 at 4:18
Can you reproduce that not-found error on an online interpreter (like how I have an example where you can see the code working at ideone.com)? Anyhow, let me know if you have questions that aren't covered in the references section and I'll add more links as appropriate.
– Charles Duffy
Nov 8 at 4:18
|
show 7 more comments
up vote
0
down vote
Try this also:
idline=$(grep id input.txt)
IFS=',' read -ra elem <<< "$idline"
idfld=0
for i in "${elem[@]}"; do
idfld=$(($idfld+1))
if [[ "$i" = "id" ]]
then
break;
fi
done
gt=0
for num in `cat input.txt|grep "^[0-9]"|cut -d"," -f${idfld}`; do
gt=$(($gt+$num ))
done
echo $gt
Thanks but this would not work in my case as I do not know which field/position id column would be.
– kumarm
Nov 8 at 1:58
Hi this is the error i am facing when i try this warning: here-document at line 3 delimited by end-of-file (wanted `$idline') I think its because of some un printable characters or the online bash terminal I am using. i will try it out tomorrow when i go to office and revert back to you.Thanks for the time
– kumarm
Nov 8 at 3:31
Sorry for the delay @sam yes your script works it gave an error saying cut starts at position 1 so i made some changes but it works thanks.
– kumarm
Nov 10 at 18:10
add a comment |
up vote
0
down vote
Try this also:
idline=$(grep id input.txt)
IFS=',' read -ra elem <<< "$idline"
idfld=0
for i in "${elem[@]}"; do
idfld=$(($idfld+1))
if [[ "$i" = "id" ]]
then
break;
fi
done
gt=0
for num in `cat input.txt|grep "^[0-9]"|cut -d"," -f${idfld}`; do
gt=$(($gt+$num ))
done
echo $gt
Thanks but this would not work in my case as I do not know which field/position id column would be.
– kumarm
Nov 8 at 1:58
Hi this is the error i am facing when i try this warning: here-document at line 3 delimited by end-of-file (wanted `$idline') I think its because of some un printable characters or the online bash terminal I am using. i will try it out tomorrow when i go to office and revert back to you.Thanks for the time
– kumarm
Nov 8 at 3:31
Sorry for the delay @sam yes your script works it gave an error saying cut starts at position 1 so i made some changes but it works thanks.
– kumarm
Nov 10 at 18:10
add a comment |
up vote
0
down vote
up vote
0
down vote
Try this also:
idline=$(grep id input.txt)
IFS=',' read -ra elem <<< "$idline"
idfld=0
for i in "${elem[@]}"; do
idfld=$(($idfld+1))
if [[ "$i" = "id" ]]
then
break;
fi
done
gt=0
for num in `cat input.txt|grep "^[0-9]"|cut -d"," -f${idfld}`; do
gt=$(($gt+$num ))
done
echo $gt
Try this also:
idline=$(grep id input.txt)
IFS=',' read -ra elem <<< "$idline"
idfld=0
for i in "${elem[@]}"; do
idfld=$(($idfld+1))
if [[ "$i" = "id" ]]
then
break;
fi
done
gt=0
for num in `cat input.txt|grep "^[0-9]"|cut -d"," -f${idfld}`; do
gt=$(($gt+$num ))
done
echo $gt
edited Nov 8 at 2:59
answered Nov 8 at 1:50
Sam
31126
31126
Thanks but this would not work in my case as I do not know which field/position id column would be.
– kumarm
Nov 8 at 1:58
Hi this is the error i am facing when i try this warning: here-document at line 3 delimited by end-of-file (wanted `$idline') I think its because of some un printable characters or the online bash terminal I am using. i will try it out tomorrow when i go to office and revert back to you.Thanks for the time
– kumarm
Nov 8 at 3:31
Sorry for the delay @sam yes your script works it gave an error saying cut starts at position 1 so i made some changes but it works thanks.
– kumarm
Nov 10 at 18:10
add a comment |
Thanks but this would not work in my case as I do not know which field/position id column would be.
– kumarm
Nov 8 at 1:58
Hi this is the error i am facing when i try this warning: here-document at line 3 delimited by end-of-file (wanted `$idline') I think its because of some un printable characters or the online bash terminal I am using. i will try it out tomorrow when i go to office and revert back to you.Thanks for the time
– kumarm
Nov 8 at 3:31
Sorry for the delay @sam yes your script works it gave an error saying cut starts at position 1 so i made some changes but it works thanks.
– kumarm
Nov 10 at 18:10
Thanks but this would not work in my case as I do not know which field/position id column would be.
– kumarm
Nov 8 at 1:58
Thanks but this would not work in my case as I do not know which field/position id column would be.
– kumarm
Nov 8 at 1:58
Hi this is the error i am facing when i try this warning: here-document at line 3 delimited by end-of-file (wanted `$idline') I think its because of some un printable characters or the online bash terminal I am using. i will try it out tomorrow when i go to office and revert back to you.Thanks for the time
– kumarm
Nov 8 at 3:31
Hi this is the error i am facing when i try this warning: here-document at line 3 delimited by end-of-file (wanted `$idline') I think its because of some un printable characters or the online bash terminal I am using. i will try it out tomorrow when i go to office and revert back to you.Thanks for the time
– kumarm
Nov 8 at 3:31
Sorry for the delay @sam yes your script works it gave an error saying cut starts at position 1 so i made some changes but it works thanks.
– kumarm
Nov 10 at 18:10
Sorry for the delay @sam yes your script works it gave an error saying cut starts at position 1 so i made some changes but it works thanks.
– kumarm
Nov 10 at 18:10
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53199880%2fhow-do-you-calculate-sum-of-a-column-without-creating-temp-files-in-shell-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Embedding a big awk script is hardly doing things "in shell script" -- you might as well have your shell script just call a Python interpreter. :)
– Charles Duffy
Nov 8 at 0:56