LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   awk files (https://www.linuxquestions.org/questions/linux-general-1/awk-files-57157/)

alaios 04-28-2003 09:56 AM

awk files
 
What are the differences between the 2 awk files . ¶I can not find them

Tinkster 04-28-2003 03:11 PM

HUH?


Which files, what are you talking about?


Cheers,
Tink

alaios 04-28-2003 03:38 PM

oups
 
oups i dit it again
:o :D




A) /^$/ {
print x += 1
}


Â) /^$/ {
print x++
}

Tinkster 04-28-2003 03:47 PM

Kalimera! :)

I'm not an expert in awk <grin> but
in C/C++ "x += 1" and "x++" can be
used synonymously...

Cheers,
Tink

alaios 04-29-2003 02:18 PM

ouaou
 
where are u from tinkster?
Geia sou ellada!!

wapcaplet 04-29-2003 02:38 PM

It looks like they're both the same. In C/C++, at least, I think they'd do the same thing.

print x++ prints x, then increments (post-increment, they call it)
print ++x increments x, then prints (pre-increment I guess)

Don't know if the same applies in awk though.

Tinkster 04-29-2003 03:18 PM

Re: ouaou
 
Quote:

Originally posted by alaios
where are u from tinkster?
Geia sou ellada!!
Living in New Zealand :)
But I used to do classical greek at Uni,
and spent a beautiful holiday in the
greek part of Cyprus once :}

Yassou,
Tink

realos 05-13-2003 05:56 AM

hi alaios,

"print x +=1;" is same as "print ++x;" or "print x =x+1;" whereas "print x++" could be substituted by "print x +=0;" or "print x =x+0;"

Hope you get the idea.

A) /^$/ {
print x += 1
}

B) /^$/ {
print x++
}

Thus A would print the number of empty lines beginning with 1 whereas B would begin with 0.


All times are GMT -5. The time now is 05:09 AM.