@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet


Comments:

<0> k
<1> hi all i try to make a command line who add the memory columns in a ps u command
<1> ps u | awk 'BEGIN {toto=0.1} NR>1 {toto=toto+$4; print $4 " "toto} END {print toto}'
<1> is the thing
<1> but i dono why the addition is an integer one :(
<1> can someone explain me why ?
<2> what do you want then ?
<1> i want to add all the memry columns of the ps u result
<1> USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND



<1> abel 5534 0.0 0.3 5684 3200 pts/0 Ss 07:32 0:00 bash
<1> abel 5561 2.8 20.2 462924 207848 pts/0 Sl 07:32 7:51 /usr/lib/firefo
<1> are supposed to give me 20.5
<2> awk '{ total+=$n } END { print total; }'
<1> it's pretty like i do but this not add the decimal part
<2> abel: in your command also, i am getting the result at the end
<2> means ?
<1> on the following file :
<1> a b c 0.4
<1> a d f 0.3
<1> a g k 0.2
<1> the result will be 0 . i want the result 0.9.
<2> $ awk '{ tot+=$4 } END { print tot }' add
<2> 0.9
<1> may be it as something to do with the fact that my station is configure for french environement...
<2> could be
<2> awk is working fine for me
<1> is there an environement variable i could set to tell awk i want to be in english environement ?
<2> LANG=C awk ...
<2> try that
<1> that's it ... many thanks
<2> np :)
<3> What did I miss? What did I miss?
<3> :)
<3> Buon giorno.
<4> hello. I have a list of records each consisting of 10 fields. I want to sort them usinf the 10th field but when I do say awk '{print $10 " "$4}' $4 overwrites the 10th field. Can anyone help please
<5> mag_, why don't you "man sort"?
<4> surprisingly a {print $4 " " $10} looks just fine
<4> Rado: i am just wondering what i'm missing here using awk
<5> mag_, typo.
<4> Rado: where?
<5> "$ -> " $



<4> Rado: maybe it is the field separators? the last one ends with no space but a newline
<4> Rado: its not a typo. the only difference I can see is the last field ending with an \n instead of a space
<4> well i solved it doing a {print $10 "\t\t\t\t" $2} , but durely its not the proper way. thanks anyways
<4> surely*
<5> Uh, I don't understand.
<5> Maybe this helps clarifiy: http://www.catb.org/~esr/faqs/smart-questions.html
<5> What does your "solution" now do different that your original attempt?
<5> that->than
<4> when I print the field $10 before $x where x is anything, $x overwrites $10 in the output. Say I have "longish" in "foo" in $x, then i get a "foogish"
<4> "longish" in $10
<5> You're doing something wrong then, because here it works. See the "Examples" in "man nawk", the "reverse fields" example wouldn't be possible if that were true.
<4> Rado: i've been going through the gawk manual and couldnt find the proper solution. I tried modifying OFS any FIELDWIDTH's but nothing. that was all i could find
<5> this works here: echo 'bla fasel kkk'|nawk '{print $3 $2 $1}'
<4> Rado: i know. there is certainly something wrong with the format of my input
<4> Rado: it is a long text file
<5> If you have a format error of the source-file, then how does your "solution help"?
<4> Rado: i indent the second field so that it does now overwrite
<4> does not*
<5> mag_, you have not understood: there is _NO_ overwriting at all.
<5> Whatever you do with the "print" cmd, it will _never_ change any data.
<4> Rado: it does not _change_ that is the output generated on my screen
<4> Rado: do you mind if i paste a couple of lines in your private? i don't want to flood here
<5> http://sial.org/pbot/awk/
<6> "mag_" at 85.107.117.239 pasted "Field $10 gets overwriten" (10 lines, 516B) at http://sial.org/pbot/18295
<5> tag, paul, do you have some kind of "homepage" for this channel, where we could put some of the links from the topic so it becomes shorter?
<5> mag_, just literally copy&pasting your input line and awk cmd-line works fine here. Try the same: copy&paste.
<4> L 2005-07-16 01:06:28 @ 66.249.66.76 --DOWNLOAD FILE-->Username: Access: Path:/var/Repository/oonder/f88.f File:3dav_testdata_ee2.zip
<4> this is one line
<4> the output is on the page
<5> I know, I don't mean here, in your shell.
<7> works for me on awk and gnu awk
<5> echo the above line | awk cmd as pasted on page.
<4> Rado: i see
<5> beebum, what is "awk" when not "gawk"?
<7> what comes with openbsd
<7> you have to load gawk separate
<8> next best thing man made - awk
<9> next? i guess we are supposed to ask "why next", or "next to what"?


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #awk
or
Go to some related logs:

install hash_hmac
#physics
#fluxbox
nonet suse
#php
#mysql
+centos +install ncftpget
grub loading error 17 ubuntu
#perl
ubuntu unable to mount selected volume



Home  |  disclaimer  |  contact  |  submit quotes