<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.nc.ut.ee/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=185.153.0.0%2F16</id>
	<title>TÜ Narva Kolledži Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.nc.ut.ee/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=185.153.0.0%2F16"/>
	<link rel="alternate" type="text/html" href="https://wiki.nc.ut.ee/index.php?title=Special:Contributions/185.153.0.0/16"/>
	<updated>2026-10-31T04:41:47Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://wiki.nc.ut.ee/index.php?title=Awk&amp;diff=1894</id>
		<title>Awk</title>
		<link rel="alternate" type="text/html" href="https://wiki.nc.ut.ee/index.php?title=Awk&amp;diff=1894"/>
		<updated>2022-12-13T19:33:50Z</updated>

		<summary type="html">&lt;p&gt;185.153.146.177: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Igor Džikajev&lt;br /&gt;
&amp;lt;h1&amp;gt;What is &amp;lt;span style=&amp;quot;background:gray;padding:2px;border-radius:5px;color:white;&amp;quot;&amp;gt;awk&amp;lt;/span&amp;gt; command?&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;background:gray;padding:2px;border-radius:5px;color:white;&amp;quot;&amp;gt;awk&amp;lt;/span&amp;gt; is a scripting language, and it is helpful when working in the command line. It&#039;s also a widely used command for text processing.&lt;br /&gt;
When using &amp;lt;span style=&amp;quot;background:gray;padding:2px;border-radius:5px;color:white;&amp;quot;&amp;gt;awk&amp;lt;/span&amp;gt;, you are able to select data – one or more pieces of individual text – based on a pattern you provide.&lt;br /&gt;
&lt;br /&gt;
For example, some of the operations you can do with &amp;lt;span style=&amp;quot;background:gray;padding:2px;border-radius:5px;color:white;&amp;quot;&amp;gt;awk&amp;lt;/span&amp;gt; are searching for a specific word or pattern in a piece of text given, or even select a certain line or a certain column in a file you provide.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt;The Basic Syntax of the &amp;lt;span style=&amp;quot;background:gray;padding:2px;border-radius:5px;color:white;&amp;quot;&amp;gt;awk&amp;lt;/span&amp;gt; command&amp;lt;/h1&amp;gt;&lt;br /&gt;
In its simplest form, the &amp;lt;span style=&amp;quot;background:gray;padding:2px;border-radius:5px;color:white;&amp;quot;&amp;gt;awk&amp;lt;/span&amp;gt; command is followed by a set of single quotation marks and a set of curly braces, with the name of the file you want to search through mentioned last.&lt;br /&gt;
&lt;br /&gt;
It looks something like this:&lt;br /&gt;
&amp;lt;p style=&amp;quot;background:rgba(50,50,50,0.1);padding:10px;&amp;quot;&amp;gt;awk &#039;{action}&#039; your_file_name.txt&amp;lt;/p&amp;gt;&lt;br /&gt;
When you want to search for text that has a specific pattern or you&#039;re looking for a specific word in the text, the command would look something like this:&lt;br /&gt;
&amp;lt;p style=&amp;quot;background:rgba(50,50,50,0.1);padding:10px;&amp;quot;&amp;gt;awk &#039;/regex pattern/{action}&#039; your_file_name.txt&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With information.txt file looking like this:&lt;br /&gt;
&amp;lt;p style=&amp;quot;background:rgba(50,50,50,0.1);padding:10px;white-space:pre;&amp;quot;&amp;gt;fristName       lastName        age     city       ID&lt;br /&gt;
&lt;br /&gt;
Thomas          Shelby          30      Rio        400&lt;br /&gt;
Omega           Night           45      Ontario    600&lt;br /&gt;
Wood            Tinker          54      Lisbon     N/A&lt;br /&gt;
Giorgos         Georgiou        35      London     300&lt;br /&gt;
Timmy           Turner          32      Berlin     N/A&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h6&amp;gt;We are able to&amp;lt;/h6&amp;gt;&lt;br /&gt;
&amp;lt;ul style=&amp;quot;list-style:none;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Print all the contents of the file using &amp;lt;span style=&amp;quot;background:rgba(50,50,50,0.1);padding:5px;&amp;quot;&amp;gt;awk &#039;{print $0}&#039; information.txt&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Add incrementing number before each line using &amp;lt;span style=&amp;quot;background:rgba(50,50,50,0.1);padding:5px;&amp;quot;&amp;gt;awk &#039;{print NR,$0}&#039; information.txt&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Print specific columns using &amp;lt;span style=&amp;quot;background:rgba(50,50,50,0.1);padding:5px;&amp;quot;&amp;gt;awk &#039;{print $1}&#039; information.txt&amp;lt;/span&amp;gt; *number represents column* It is also possible to print out multiple by adding $n after $1 &amp;lt;span style=&amp;quot;background:rgba(50,50,50,0.1);padding:5px;&amp;quot;&amp;gt;awk &#039;{print $1, $4}&#039; information.txt&amp;lt;/span&amp;gt; or $NF to print out last column&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Print specific lines of a column by adding &amp;lt;span style=&amp;quot;background:rgba(50,50,50,0.1);padding:5px;&amp;quot;&amp;gt;head or tail command to existing command // awk &#039;{print $1}&#039; information.txt | head -1 &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Use regex &amp;lt;span style=&amp;quot;background:rgba(50,50,50,0.1);padding:5px;&amp;quot;&amp;gt;awk &#039; /io/{print $0}&#039; information.txt&amp;lt;/span&amp;gt; this will print out lines containing &amp;quot;io&amp;quot;&lt;br /&gt;
&amp;lt;li&amp;gt;Use comparisson operators &amp;lt;span style=&amp;quot;background:rgba(50,50,50,0.1);padding:5px;&amp;quot;&amp;gt;awk &#039;$3 &amp;lt;  40 { print $0 }&#039; information.txt&amp;lt;/span&amp;gt; this will only print out lines where 3rd column (age) is &amp;lt;40&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
This wraps up everything there is to say about &amp;lt;span style=&amp;quot;background:gray;padding:2px;border-radius:5px;color:white;&amp;quot;&amp;gt;awk&amp;lt;/span&amp;gt;.&lt;/div&gt;</summary>
		<author><name>185.153.146.177</name></author>
	</entry>
</feed>