<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Linux-AWK%2FC2%2FLoops-in-awk%2FEnglish-timed</id>
		<title>Linux-AWK/C2/Loops-in-awk/English-timed - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Linux-AWK%2FC2%2FLoops-in-awk%2FEnglish-timed"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Linux-AWK/C2/Loops-in-awk/English-timed&amp;action=history"/>
		<updated>2026-04-28T02:56:45Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Linux-AWK/C2/Loops-in-awk/English-timed&amp;diff=48470&amp;oldid=prev</id>
		<title>Sandhya.np14 at 16:55, 25 July 2019</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Linux-AWK/C2/Loops-in-awk/English-timed&amp;diff=48470&amp;oldid=prev"/>
				<updated>2019-07-25T16:55:16Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 16:55, 25 July 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 411:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 411:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|-&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|-&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;| 09:41&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;| 09:41&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|It also has '''comments''' preceded with '''hash ''' &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;sysmbol&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|It also has '''comments''' preceded with '''hash ''' &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;symbol&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|-&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|-&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Sandhya.np14</name></author>	</entry>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Linux-AWK/C2/Loops-in-awk/English-timed&amp;diff=48095&amp;oldid=prev</id>
		<title>Sandhya.np14 at 09:16, 10 July 2019</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Linux-AWK/C2/Loops-in-awk/English-timed&amp;diff=48095&amp;oldid=prev"/>
				<updated>2019-07-10T09:16:36Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://script.spoken-tutorial.org/index.php?title=Linux-AWK/C2/Loops-in-awk/English-timed&amp;amp;diff=48095&amp;amp;oldid=45292&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Sandhya.np14</name></author>	</entry>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Linux-AWK/C2/Loops-in-awk/English-timed&amp;diff=45292&amp;oldid=prev</id>
		<title>PoojaMoolya: Created page with &quot;{|border=1 | &lt;center&gt;'''Time'''&lt;/center&gt; | &lt;center&gt;'''Narration'''&lt;/center&gt;  |- |00:01 | Hello and Welcome to this spoken tutorial on '''Loops''' in '''awk'''.  |- | 00:06 | I...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Linux-AWK/C2/Loops-in-awk/English-timed&amp;diff=45292&amp;oldid=prev"/>
				<updated>2018-12-14T06:22:27Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{|border=1 | &amp;lt;center&amp;gt;&amp;#039;&amp;#039;&amp;#039;Time&amp;#039;&amp;#039;&amp;#039;&amp;lt;/center&amp;gt; | &amp;lt;center&amp;gt;&amp;#039;&amp;#039;&amp;#039;Narration&amp;#039;&amp;#039;&amp;#039;&amp;lt;/center&amp;gt;  |- |00:01 | Hello and Welcome to this spoken tutorial on &amp;#039;&amp;#039;&amp;#039;Loops&amp;#039;&amp;#039;&amp;#039; in &amp;#039;&amp;#039;&amp;#039;awk&amp;#039;&amp;#039;&amp;#039;.  |- | 00:06 | I...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{|border=1&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Time'''&amp;lt;/center&amp;gt;&lt;br /&gt;
| &amp;lt;center&amp;gt;'''Narration'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:01&lt;br /&gt;
| Hello and Welcome to this spoken tutorial on '''Loops''' in '''awk'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:06&lt;br /&gt;
| In this tutorial we will learn about- '''while'''&lt;br /&gt;
&lt;br /&gt;
'''do-while''',  '''for ''' and more '''looping constructs '''in''' awk'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:16&lt;br /&gt;
|We will do this through some examples.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:20&lt;br /&gt;
| To record this tutorial, I am using &lt;br /&gt;
&lt;br /&gt;
'''Ubuntu Linux 16.04 Operating System '''and''' ''' '''gedit text editor 3.20.1'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:32&lt;br /&gt;
|You can use any text editor of your choice.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:36&lt;br /&gt;
| To practice this tutorial, you should have gone through the previous '''awk''' tutorials on our website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:43&lt;br /&gt;
| You should have familiarity with any '''programming language''' like C or C++ &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:50&lt;br /&gt;
| If not, then please go through the corresponding tutorials on our website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:56&lt;br /&gt;
| The files used in this tutorial are available in the '''Code Files''' link on this tutorial page.&lt;br /&gt;
&lt;br /&gt;
Please download and extract them.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:06&lt;br /&gt;
| A '''loop''' allows us to perform one or more actions repeatedly.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:12&lt;br /&gt;
|'''while, do-while '''and''' for '''are the available '''loops''' in '''awk'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:18&lt;br /&gt;
| The syntax of '''while''' '''loop''' can be seen here.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:22&lt;br /&gt;
|'''While loop '''first checks whether the specified '''condition''' is true. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:27&lt;br /&gt;
|If yes, then it executes the code within the '''body.'''&lt;br /&gt;
&lt;br /&gt;
This '''loop '''will be repeated as long as the specified '''while condition '''is '''true'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:37&lt;br /&gt;
| We will use the same '''awkdemo.txt '''file, that we have used earlier. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:43&lt;br /&gt;
| I have already written a script named '''while_loop.awk'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:48&lt;br /&gt;
|The same file is available in the '''Code Files''' link of this tutorial.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:53&lt;br /&gt;
| Here we have set the '''field separator''' as '''Pipe symbol.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:58&lt;br /&gt;
| Initially, we have to the set the value of the '''loop variable i '''as 1. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:04&lt;br /&gt;
| Here, we have taken one more variable '''f''' and initialized it to 1.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:10&lt;br /&gt;
|'''Variable f''' represents the '''field counter '''or the position of the '''fields''' for each '''record'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:17&lt;br /&gt;
| Now, in the '''while condition''', we check if '''i''' is less than or equal to 3.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:23&lt;br /&gt;
| If yes, then it will print the value in the '''f'''&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt;''' field, '''for that record in '''awkdemo.txt '''file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:31&lt;br /&gt;
| Then we will increment the '''field counter f''' by 1.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:36&lt;br /&gt;
| After that, we will also increment the value of '''loop variable i''' by 1.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:43&lt;br /&gt;
| This '''printf''' is for printing a '''newline character''' at the end of each row.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:49&lt;br /&gt;
| This '''loop''' will be executed for all the records in the '''awkdemo.txt''' file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:55&lt;br /&gt;
|Which means the first 3 fields will get printed for each record.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:00&lt;br /&gt;
| Let’s execute this code now.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:03&lt;br /&gt;
| Open the '''terminal''' by pressing '''Ctrl, Alt''' and '''T''' keys.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:09&lt;br /&gt;
| Go to the folder in which you downloaded and extracted the '''Code Files''' using '''cd command'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:16&lt;br /&gt;
| Now type: '''awk space hyphen small f space while_loop.awk space awkdemo.txt'''&lt;br /&gt;
&lt;br /&gt;
Press '''Enter'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:29&lt;br /&gt;
| Observe that we get the first three '''fields''' of all the rows in the output.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:35&lt;br /&gt;
| Let us do the same with the '''do-while loop'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:38&lt;br /&gt;
| The syntax of '''do-while loop''' can be seen here.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:42&lt;br /&gt;
|The '''do-while loop''' always executes the code inside the '''body''' once.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:47&lt;br /&gt;
|Then it checks the specified '''condition.''' And repeats the code inside the '''body''', as long as the specified '''condition'''is '''true'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:56&lt;br /&gt;
| I have already written a script and named it as '''do_loop.awk'''&lt;br /&gt;
&lt;br /&gt;
The same file is available in the '''Code Files '''link. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:06&lt;br /&gt;
| In this code, these are the '''statements '''within the '''do loop, '''which will be executed first.&lt;br /&gt;
&lt;br /&gt;
This is the '''condition '''that will be checked.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:15&lt;br /&gt;
|After that, the '''statements '''inside the '''loop '''will be executed repeatedly as long as the '''condition '''is '''true'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:23&lt;br /&gt;
| This '''loop''' will iterate for all the records in the '''awkdemo.txt''' file&lt;br /&gt;
&lt;br /&gt;
Which means the first 3 fields will get printed for all the records.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:33&lt;br /&gt;
| Let’s switch to the '''terminal. '''Let me clear the''' terminal.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:38&lt;br /&gt;
|Now type: '''awk space hyphen small f space do underscore loop dot awk space awkdemo dot txt'''&lt;br /&gt;
&lt;br /&gt;
Press '''Enter'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:52&lt;br /&gt;
| We get the same output. Then why do we have both '''while '''and '''do-while loops'''? &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:58&lt;br /&gt;
|Let us understand the difference.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:00&lt;br /&gt;
| Switch to the file '''while underscore loop dot awk'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:05&lt;br /&gt;
|Now, change the value of '''loop counter i '''from 1 to 4.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:11&lt;br /&gt;
| This will make the specified '''condition false''' from the beginning.&lt;br /&gt;
&lt;br /&gt;
So this means, we should not get any output.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:19&lt;br /&gt;
| Save the file and switch to the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:22&lt;br /&gt;
| Clear the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
Now press  the Up arrow key until you get the command for executing the '''while loop.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:30&lt;br /&gt;
|Now press '''Enter.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:32&lt;br /&gt;
| See, we are not getting any output apart from blank lines.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:37&lt;br /&gt;
|For each record in the '''awkdemo.txt''' file, blank lines are getting printed in the output.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:44&lt;br /&gt;
| Now, let us make some changes in the '''do loop '''file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:48&lt;br /&gt;
| Switch to the file '''do underscore loop dot awk'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:53&lt;br /&gt;
|Change the value of '''i '''from 1 to 4.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:57&lt;br /&gt;
|Save the file and switch to the '''terminal.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:01&lt;br /&gt;
| Clear the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
Now press the Up arrow key until you get the command for '''do loop.'''&lt;br /&gt;
&lt;br /&gt;
Press '''Enter.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:10&lt;br /&gt;
| In the output, only the first field for each row is printed.&lt;br /&gt;
&lt;br /&gt;
What is the reason?&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:16&lt;br /&gt;
| For each row, '''awk''' first prints the value at the first''' field, ''' because value of '''variable f '''is initialized to '''1.'''&lt;br /&gt;
&lt;br /&gt;
Then the '''condition '''is checked.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:28&lt;br /&gt;
|Since the value of the '''loop counter i '''is 4, then the '''condition '''is '''false'''.&lt;br /&gt;
&lt;br /&gt;
Hence, the '''loop '''is terminated there only, for that record.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:39&lt;br /&gt;
| This '''loop''' will iterate for all the records in the '''awkdemo.txt''' file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:44&lt;br /&gt;
|Which means the first '''field''' for each record will get printed.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:49&lt;br /&gt;
| We are getting the output at least once for each record.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:53&lt;br /&gt;
|Use the '''do-while loop, '''for a job to be executed at least once, irrespective of any other '''condition'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:01&lt;br /&gt;
| We can do the same with the '''for loop''' also.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:05&lt;br /&gt;
|  The syntax of '''for loop '''can be seen here.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:09&lt;br /&gt;
|The '''for statement''' starts by executing '''''initialization'''''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:14&lt;br /&gt;
|Then, as long as the '''''condition''''' is true, it repeatedly executes the '''''statements''' ''within and then '''''increments'''''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:23&lt;br /&gt;
|Assuming your familiarity with a language like '''C''' or '''C++''', I am not explaining the syntax in detail.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:30&lt;br /&gt;
| This is how  '''for loop '''for this '''condition''' looks like.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:35&lt;br /&gt;
|Here, '''initialization, condition''' checking and variable incrementation are done in the same line.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:43&lt;br /&gt;
|Try this out by yourself.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:46&lt;br /&gt;
| There are some more''' looping constructs '''&lt;br /&gt;
&lt;br /&gt;
'''break''',  '''continue''',  '''exit'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:53&lt;br /&gt;
|We will see some relevant examples on these in further tutorials.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:58&lt;br /&gt;
| We may have a single and multiline '''comments''' in our file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:03&lt;br /&gt;
|Here notice that the single line '''comments''' are declared with single '''hash '''(#) symbol'''.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:10&lt;br /&gt;
|The multiline '''comments''' are declared with the help of double '''hash '''(##) symbol.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:16&lt;br /&gt;
| Now, there is no point of checking and printing these '''comments''' in the output. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:22&lt;br /&gt;
|We have to skip the lines starting with '''hash '''(##) symbol.&lt;br /&gt;
&lt;br /&gt;
How can we do this?&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:28&lt;br /&gt;
| Recall the case of giving 50% increment in the stipend for those who are getting more than 8000.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:36&lt;br /&gt;
|We will use the same example for skipping the '''comments'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:40&lt;br /&gt;
| I have created a file named''' next.awk '''as shown here for this execution.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|08:47&lt;br /&gt;
| Now, what does this command mean?&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:50&lt;br /&gt;
| '''awk''' will search for the pattern, '''caret sign hash symbol(^#) '''at the beginning of each line.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:57&lt;br /&gt;
|If the pattern is found, the keyword '''next '''tells '''awk''' to skip the current line immediately.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:04&lt;br /&gt;
|Then '''awk''' will start processing from the next line in the file.&lt;br /&gt;
&lt;br /&gt;
This will save the processing time.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:12&lt;br /&gt;
| Switch to the '''terminal''' and type the command as shown here and &lt;br /&gt;
&lt;br /&gt;
Press '''Enter.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:20&lt;br /&gt;
| We get the output without any '''comments.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:24&lt;br /&gt;
| Suppose, we have the students’ records in multiple files with the same format.&lt;br /&gt;
&lt;br /&gt;
Say in '''awkdemo_mod.txt''' and '''awkdemo2.txt'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:37&lt;br /&gt;
| See, it is similar to our previous file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:41&lt;br /&gt;
|It also has '''comments''' preceeded with '''hash ''' sysmbol.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:45&lt;br /&gt;
|And it has large text at the end with double '''hash #&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt;''' symbol.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:50&lt;br /&gt;
| So our data is in two different files.&lt;br /&gt;
&lt;br /&gt;
'''awk''' should process both the files to give an increment to all the students.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:59&lt;br /&gt;
|Once we reach double '''hash'''(##) symbol of the first file, '''awk''' should stop processing that file entirely.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:06&lt;br /&gt;
|Then it has to start the execution from the next file.&lt;br /&gt;
&lt;br /&gt;
This will save the processing time.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:13&lt;br /&gt;
| Modify the '''next.awk '''as shown here.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:17&lt;br /&gt;
|I have added '''dollar zero tilde slash caret symbol double hash slash within braces nextfile semicolon '''below the '''begin statement'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:29&lt;br /&gt;
|This will search for double '''hash #''' symbol at the beginning of each line.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:34&lt;br /&gt;
|If found, '''awk''' will skip the current file to process the next file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:39&lt;br /&gt;
| Save this file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|10:41&lt;br /&gt;
| Switch to the the '''terminal '''and type the following command.&lt;br /&gt;
&lt;br /&gt;
Press''' Enter'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:48&lt;br /&gt;
| See, we are getting the output from both the files.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:53&lt;br /&gt;
| This brings us to the end of this tutorial.&lt;br /&gt;
&lt;br /&gt;
Let us summarize.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:58&lt;br /&gt;
|In this tutorial we learnt about-  '''while''',  '''do… while''',  '''for''',  '''next''',  '''nextfile '''in''' awk'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 11:06&lt;br /&gt;
| As an assignment for the student records of '''awkdemo2.txt''',  print only even '''fields'''(i.e. '''field''' 2, '''field''' 4 etc,  irrespective of how many '''fields''' are there in the '''input file'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 11:22&lt;br /&gt;
| The video at the following link summarises the Spoken Tutorial project.&lt;br /&gt;
&lt;br /&gt;
Please download and watch it.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 11:30&lt;br /&gt;
| The Spoken Tutorial Project team conducts workshops using spoken tutorials and gives certificates on passing online tests.&lt;br /&gt;
&lt;br /&gt;
For more details, please write to us.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 11:43&lt;br /&gt;
| Do you have questions in THIS Spoken Tutorial?&lt;br /&gt;
&lt;br /&gt;
Please visit this site.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 11:49&lt;br /&gt;
| Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.&lt;br /&gt;
&lt;br /&gt;
More information on this mission is available at this link.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 12:01&lt;br /&gt;
| This script has been contributed by Antara.&lt;br /&gt;
&lt;br /&gt;
And this is Praveen from IIT Bombay signing off.&lt;br /&gt;
&lt;br /&gt;
Thanks for joining.&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>PoojaMoolya</name></author>	</entry>

	</feed>