gawk parameter questions

motioneye used Ask the Experts™
I saw some script that in our applications server has the gawk.exe with parameter as  below, do anyone here familiar with gawk and mind to explain what is this parameter does ?

gawk.exe "!x[$0]++"
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
gawk is a gnu implementation of awk which is a programming language designed for text processing and typically used as a data extraction and reporting tool. It is a standard feature of most Unix-like operating systems. gawk.exe is a windows wrapped gawk implementation. as for the parameter sent to it, this is a regex string that is searching something apparently in an array sent to it.

Telling you exactly what it does is rather difficult without more of the code. but it seems to be something along the lines of match anything that is NOT x and any char in the $0 set
Test your restores, not your backups...
Top Expert 2016
That command, assuming you also provide a data file name to process will remove duplicate lines from the file and print each unique line only once.  It's a bit tricky to understand, take a look at this discussion for the mechanics.

remove duplicate lines using awk | Unix Linux Forums | Shell Programming and Scripting


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial