Visit Our UNIX and Linux User Community

Top Forums UNIX for Advanced & Expert Users size for sum variable limitation on awk Post 302508192 by cwitarsa on Saturday 26th of March 2011 02:11:01 PM
Old 03-26-2011
CPU & Memory size for sum variable limitation on awk


first, truth been told, I'm not even close to be advanced user. I'm posting here because maybe my question is complicated enough to need your expert help

I need to use awk (or nawk - I don't have gawk) to validate some files by computing the total sum for a large numeric variable.
It can be that my OS does not support it or it can be as simply as modify my command

in this forum I found a simpler command, but that can indicates a limitation

/da9$ echo "12345678910 12345678910" | awk '{sum=$1; sum+=$2; print sum}'
/da9$ echo "1234567891 1234567891" | awk '{sum=$1; sum+=$2; print sum}'
/da9$ echo "123456789 123456789" | awk '{sum=$1; sum+=$2; print sum}'

/da9$ file `which awk`
/usr/bin/awk: executable (RISC System/6000) or object module
$ uname -s -r -v
AIX 1 6
$ uname -a
AIX blabla 1 6 00C608324C00

can someone help me make this sum or point me any configuration requirements?

in reality, this is the command I want to use (it can be that the inner print is causing the e+ notation, but I've tried printf and got even worse results):

cat a01.txt | nawk -F"\t" '{print $7,$8,$2";"$18}'| sort | nawk -F";" 'BEGIN{var="inicio";soma=0};{if(var!=$1) {if(var!="inicio") {print var,soma ; var=$1 ; soma=$2} else {var=$1;soma=$2}} else {var=$1;soma=soma+$2} };END{printf "\n",var,"%17.2f",soma}'


CashB Aprovado S-01 1533.44
Compr Aprovado S-01 3.23697e+09

---------- Post updated at 03:11 PM ---------- Previous update was at 02:45 PM ----------


credits to my wonderful friend Luiz Germano (who even called me at a Saturday!)

the problem really was the inner print and the solution was to format both variables

cat a01.txt | nawk -F"\t" '{print $7,$8,$2";"$18}'| sort | nawk -F";" 'BEGIN{var="inicio";soma=0};{if(var!=$1) {if(var!="inicio") {printf ("%s %17.2f\n",var,soma) ; var=$1 ; soma=$2} else {var=$1;soma=$2}} else {var=$1;soma=soma+$2} };END{printf "%s %17.2f\n",var,soma}'

you can use this as a sumif on excel - sum one column by the values of another column - sumif with awk
Test Your Knowledge in Computers #148
Difficulty: Easy
A free derivative of BSD Unix, 1992BSD, was released in 1992 and led to the NetBSD and FreeBSD projects.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

Size Limitation for a user directory

Hi all, I want to set a size limitation for some user in the system, for an example, each user only have 5MB free space in the system. The user cannot user more than 5 MB space. Is it possible to do this? Thanks! (1 Reply)
Discussion started by: felix_koo
1 Replies

2. HP-UX

HP-UX 11i - File Size Limitation And Number Of Folders Limitation

Hi All, Can anyone please clarify me the following questions: 1. Is there any file size limitation in HP-UX 11i, that I can able to create upto certain size of file (say 2 GB) and not more then that???? 2. At max. how many files we can able to keep inside a folder???? 3. How many... (2 Replies)
Discussion started by: sundeep_mohanty
2 Replies

3. Shell Programming and Scripting

File size limitation of unix sort command.

hi , iam trying to sort millions of records which is delimited and i cant able to use sort command more than 60 million..if i try to do so i got an message stating that "File size limit exceeded",Is there any file size limit for using sort command.. How can i solve this problem. thanks ... (7 Replies)
Discussion started by: cskumar
7 Replies

4. Linux

File size limitation for rcp

Hi I am trying to rcp a file from Solaris box to Linux. When the file size is 2,205,255,047, the rcp fails with the message Jan 10 01:11:53 hqsas167 rsh: pam_authenticate: error Authentication failed However when I rcp a file with smaller size - 9,434,477 - the rcp completes with... (2 Replies)
Discussion started by: schoubal
2 Replies

5. Shell Programming and Scripting

Size limitation in Tar command

Hi to every body there, I am new this forum and this is my first post. I am a new user of Unix, is there any size limitation of files while creating tar file. Thanks in advance (4 Replies)
Discussion started by: Manvar Khan
4 Replies

6. Shell Programming and Scripting

fetchmail - log file size limitation

Hi, I am using fetchmail in my application so as to download mails to the localhost where the application is hosted from the mailserver.Fetchmail is configured as as to run as a daemon polling mails during an interval of 1sec. So my concern here is, during each 2sec it is writing two... (10 Replies)
Discussion started by: DILEEP410
10 Replies

7. UNIX for Advanced & Expert Users

Find command -size option limitation ?

Hi All, I ran code in test environment to find the files more than 1TB given below is a snippet from code: FILE_SYSTEM=/home/arun MAX_FILE_LIMIT=1099511627776 find $FILE_SYSTEM -type f -size +"$MAX_FILE_LIMIT"c -ls -xdev 2>/dev/null | while read fname do echo "File larger than... (3 Replies)
Discussion started by: Arunprasad
3 Replies

8. Solaris

How to extend 2 GB file size limitation

Hello All, I am using a SunOS machine. My application creates output files for the downstream systems. However output files are restricted to 2GB of file size in SunOS due to which I am forced to create multiple files which is not supported by the downstream due to some limitations. Is... (5 Replies)
Discussion started by: pasupuleti81
5 Replies

9. Shell Programming and Scripting

Search two patterns using awk to print the variable sum

Coins.txt: gold 1 1986 USA American Eagle gold 1 1908 Austria-Hungary Franz Josef 100 Korona silver 10 1981 USA ingot gold 1 1984 Switzerland ingot gold 1 1979 RSA Krugerrand gold 0.5 1981 RSA Krugerrand gold 0.1 1986 PRC Panda silver 1 1986 USA Liberty dollar gold 0.25 1986 USA Liberty... (2 Replies)
Discussion started by: Ramesh M
2 Replies

10. Linux

File size limitation in Linux

Hi friends, I tried to take a backup of my PC using tar command. But it ended with an error tar: /home/backup/back.tar.gz: Cannot write: No space left on device tar: Error is not recoverable: exiting now But i checked the disk space and there is enough space is available. ]# df Filesystem... (11 Replies)
Discussion started by: siva3492
11 Replies
XTERMCONTROL(1) 						   User Commands						   XTERMCONTROL(1)

xtermcontrol - dynamic control of XFree86 xterm properties. SYNOPSIS
xtermcontrol [OPTIONS]... DESCRIPTION
xtermcontrol makes it easy to change colors, title, font and geometry of a running XFree86 xterm(1), as well as to report the current set- tings of the aforementioned properties. Window manipulations de-/iconify, raise/lower, maximize/restore and reset are also supported. To complete the feature set; xtermcontrol lets advanced users issue any xterm control sequence of their choosing. OPTIONS
--fg=COLOR Set foreground color (see also COLOR NAMES). --bg=COLOR Set background color. --colorN=COLOR Set N'th [0-15] color. --highlight=COLOR Set highlight color. --cursor=COLOR Set cursor color. --mouse-fg=COLOR Set mouse pointer foreground color. --mouse-bg=COLOR Set mouse pointer background color. --font=FONT Set font name (see also FONT NAMES). Alternatively it is possible to specify a fontmenu index as '#[0-6]' or navigate the fontmenu by relative sizes as '#+N' or '#-N', where N is an optional integer. --title=STRING Set window title. Note that mechanisms like the bash(1) PROMPT_COMMAND may overwrite the title. --geometry=WIDTHxHEIGHT+XOFF+YOFF Set size and/or position. Through its control sequences the xterm only recognize positive XOFF and YOFF offsets, which are pixels relative to the upper left hand corner of the display. xtermcontrol is therefore unable to handle negative offsets as described in the X(7x) GEOMETRY SPECIFICATIONS and therefore truncates negative values to zero. --get-fg Report foreground color. --get-bg Report background color. --get-colorN Report N'th [0-15] color. --get-highlight Report highlight color. --get-cursor Report cursor color. --get-mouse-fg Report mouse pointer foreground color. --get-mouse-bg Report mouse pointer background color. --get-font Report font. --get-title Report window title. --get-geometry Report size and position. The size of the text area is reported in characters and the position is reported in pixels relative to the upper left hand corner of the display. --maximize Maximize window. --restore Restore maximized window. --iconify Iconify window. --de-iconify De-iconify window. --raise Raise window. --lower Lower window. --reset Full reset. --raw=CTLSEQS Issue raw control sequence (see also XTERM CONTROL SEQUENCES). --file=FILE Force xtermcontrol to read configurations (see also CONFIGURATION) from FILE instead of the standard personal initialization file ~/.xtermcontrol. --force, -f Skip TERM environment variable check. --verbose, -v Print verbose reports. --help, -h Print help message and exit. --version Print the version number and exit. CONFIGURATION
xtermcontrol reads a default, ~/.xtermcontrol, or a user specified configuration file on startup. Each line in the file is either a com- ment or contains an attribute. Attributes consist of a keyword and an associated value: keyword = value # comment The valid keyword/value combinations are: foreground="COLOR" background="COLOR" highlight="COLOR" cursor="COLOR" mouse-foreground="COLOR" mouse-background="COLOR" geometry="WIDTHxHEIGHT+XOFF+YOFF" font="FONT" color0="COLOR" color1="COLOR" color2="COLOR" color3="COLOR" color4="COLOR" color5="COLOR" color6="COLOR" color7="COLOR" color8="COLOR" color9="COLOR" color10="COLOR" color11="COLOR" color12="COLOR" color13="COLOR" color14="COLOR" color15="COLOR" Whitespace is ignored in attributes unless within a quoted value. The character '#' is taken to begin a comment. Each '#' and all remaining characters on that line is ignored. FONT NAMES
xtermcontrol accepts any X(7x) FONT NAMES. Font names like '-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1' are very cumber- some to write, so it is convenient to make use of aliases, e.g. 'fixed' or '8x13', if present in fonts.alias files of the font directo- ries. COLOR NAMES
xtermcontrol accepts any X(7x) COLOR NAMES. Basically this means that colors are specified by name or rgb value, e.g. 'blue', 'rgb:0000/0000/FFFF' or '#00F'. Colors are typically reported by the xterm in a device-dependent numerical form, e.g. 'rgb:0000/0000/FFFF'. Note that old syntax rgb values should always be quoted to avoid '#' being interpreted as the beginning of a comment by the shell (see also FILES). XTERM CONTROL SEQUENCES
The secret behind xtermcontrol is xterm control sequences. All the possible (there are a plethora of them) control sequences are documented in ctlseqs.txt, found in the xterm(1) distribution (see also FILES). TROUBLESHOOTING
If read/write permissions on the tty's are changed so that special group membership is required to be able to write to the pseudo terminal, the easiest workaround is to install xtermcontrol setuid root. Xterm(1) has three resources, allowWindowOps, allowTitleOps, and allowFontOps, that enables or disables special operations which xtermcon- trol relies on. If any of these resources are set (or defaults) to 'false' xtermcontrol may hang. The resources corresponds to xtermcon- trol options as: allowWindowOps: --raise --lower --restore --maximize --iconify --de-iconify --get-title --geometry --get-geometry allowTitleOps: --title allowFontOps: --font --get-font All three resources can usually be enabled for the current xterm session via a menu; ctrl+rightclick and look for menu item names like 'Allow Window Ops'. To set these resource values persistently you can add the following to either your local ~/.Xdefaults file, or to a system-wide resource file like /etc/X11/app-defaults/XTerm: *VT100.allowWindowOps: true *VT100.allowTitleOps: true *VT100.allowFontOps: true FILES
<XRoot>/X11/rgb.txt Default rgb color name file location. ctlseqs.txt Xterm control sequences documentation. Distributed with xterm from SEE ALSO
xterm(1), X(7x) COPYRIGHT
Copyright (C) 2002-2009 Jess Thrysoee <> xtermcontrol 2.10 October 17, 2009 XTERMCONTROL(1)

Featured Tech Videos

All times are GMT -4. The time now is 10:32 PM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy