Remove filenamefrom the end of the command awk:
Edit
awk '{sum+=$1} END {print sum}' read
to
awk '{sum+=$1} END {print sum}'
The first one will tell you awkto get the input file from a file with a name read, where the second is specified awkto get the input from standard input.
How you use the script: ./read.sh <data
You feed the input through standard input.
Alternatively, if you always want the script to read input from a file with a name data, you can do:
awk '{sum+=$1} END {print sum}' data
and run the script like: ./read.sh
source
share