|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
[Solved] Using awk withing a shell script
I am trying to use an awk command within a ksh script but it is not working - I am able to run from command line with no problem. It does not err out - it just does not produce a file with final count. Code:
awk "{s+=$0} END {print s}" es.out > es.cntAny help would be greatly appreciated. Thanks Last edited by radoulov; 01-22-2013 at 05:17 PM.. Reason: Marked as solved. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Replace double quotes
" with single quotes
' Code:
awk '{s+=$0} END {print s}' es.out |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
I tried that just now - same result.
|
|
#4
|
|||
|
|||
|
Show the input you have and the output you want.
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
The input is a file with a different number on each line (es.out) - I want to add the numbers for a total in the output file (es.cnt)
HTML Code:
Input -
252
428
1174
12
29
539
35
12
30
7
6
3
5
Output -
2532
|
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Works fine here, but try $1 instead of $0. Maybe your version of awk refuses to add numbers with whitespace in front of them.
|
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Works perfectly now! Thank you so much!!!
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Call shell script function from awk script | aishsimplesweet | Shell Programming and Scripting | 2 | 08-25-2011 10:42 AM |
| awk splits file in to multiple - how to get filenames in variables withing ksh? | spidermike | Shell Programming and Scripting | 2 | 03-17-2010 11:27 AM |
| create a shell script that calls another script and and an awk script | magikminox | Shell Programming and Scripting | 0 | 06-26-2008 02:50 AM |
| html withing shell scripts,how?? | divzz | Shell Programming and Scripting | 6 | 05-28-2008 08:11 AM |
| Search withing the line | Nafanja | Shell Programming and Scripting | 4 | 11-29-2007 12:04 PM |
|
|